This technical tip allows developers how to protect a Excel workbook from unauthorized access using Saaspose.Cells REST API in Java applications.
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
This technical tip allows developers how to protect a Excel workbook from unauthorized access using Saaspose.Cells REST API in Java applications. Some important steps for performing this task is to build URI to Protect Workbook, sign URI, serialize the JSON request content, Represents Protection Types and use Protection Class above to apply the protection.
Sample Code for protecting Excel workbook from unauthorized access
//build URI to Protect Workbook
string strURI = "http://api.saaspose.com/v1.0/cells/input.xls/protection";
//sign URI
string signedURI = Sign(strURI);
//serialize the JSON request content
Protection protection = new Protection();
protection.setProtectionType(ProtectionType.All);
protection.setPassword("password");
String strJSON = "";
Gson gson = new Gson();
strJSON = gson.toJson(encryption, Encryption.class);
InputStream responseStream = ProcessCommand(signedURI, "POST", strJSON);
String strResponse = StreamToString(responseStream);
//Following is the Protection Class used above
public class Protection
{
public Protection()
{
}
private ProtectionType ProtectionType;
private String Password;
public ProtectionType getProtectionType(){return ProtectionType;}
public String getPassword(){return Password;}
public void setProtectionType(ProtectionType ProtectionType){ this.ProtectionType=ProtectionType;}
public void setPassword(String Password ){ this.Password=Password;}
}
///
/// Represents Protection Types
///
public enum ProtectionType
{
All,
Structure,
Windows,
None
}
More about Saaspose.Cells
- Homepage of Saaspose.Cells: http://saaspose.com/api/cells
- More Technical Tips by Saaspose.Cells: http://saaspose.com/docs/display/cells/1.2+-+Saaspose.Cells+Examples
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)