Issue with protected .xls file

hi there

we have password protected .xls file and want to convert into pdf password protected file.

as we do :

we have function that return as byte[]

start function

workbook = New Aspose.Cells.Workbook

'workbook.Open(Request.PhysicalApplicationPath & strInputFilename)

workbook.Open(strInputFilename, Aspose.Cells.FileFormatType.Excel2003, "007")

'ExceltoPDF(workbook, strOutputFilename)

strFileName = Path.GetFileName(strInputFilename)

strFileName = strFileName.Substring(0, strFileName.LastIndexOf(".")) & ".xml"

workbook.Save(strServerPath & strFileName, Aspose.Cells.FileFormatType.AsposePdf)

pdf.BindXML(strServerPath & strFileName, Nothing)

pdf.Security = New Aspose.Pdf.Security

pdf.Security.UserPassword = "007"

'remove the temporary xml file

File.Delete(strServerPath & strFileName)

Return pdf.GetBuffer()

end function

on pdf.GetBuffer() we get exception : object reference not set to an instance of an object.

help me to find the solution on this issue.

regard

jazz

Hi,

Thank you for considering Aspose.

We have found your mentioned issue after an initial test. We will look into it and check if the issue is with Aspose.Cells component or Aspose.Pdf component and try to resolve it asap.

Thank You & Best Regards,

Hi,

I am the developer of Aspose.Pdf responsible for this issue. I have reproduced this problem, and logged it as PDFNET-9607 in our defect database. We will resolve it ASAP. Sorry for inconvenience.

BRs

Hi,

We have found the reasons incurring this problem, in order to test it better, could you tell us what you want to do after getting the buffer as byte[], do you want to save it as .pdf file or have other purposes.

BRs

yes, we want to save it into table column.

Hi,

Could you offer the complete code snippet or example so that we could test it better? Thanks.

BRs

we are attaching example so you can understand better. I am also sending excel file for your testing.

password ="007"

Thank in Advance

Hi,

The issue has been resolved. Please try the attached dll before we publish our new hotfix. Thanks.

Best regards.

hi,

That is working fine. There is one more issue Like. if we want open excel file. After open we want to check it is password protectet or not.

On the base of this we want to do some thing. here is code:

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();

workbook.Open("c:\\templatefile.xls");

if (workbook.IsProtected)

{

//here goes your code for protected file

}else

{

//here goes your code for not protectet file

}

waiting for your reply

regards

Hi,

Well I am afraid Aspose.Cells does not support to check whether the file is open/modify protected. You may only use Workbook.IsProtected to check whether workbook is protected using windows/structure lock options (In MS Excel check menu options Tool--> Protection --> Protect Workbook).

Thank you.

Hi,

Please try our latest version v5.1.4:
http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry265124.aspx
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:DoNotOptimizeForBrowser/>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val=“–”/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

We have supported setting encryption and protection settings on the generated pdf file

Sample code:

workbook.Open("test.xls");

PdfSaveOptions saveOption = new PdfSaveOptions();

saveOption.SecurityOptions = new Rendering.PdfSecurity.PdfSecuritySettings();

saveOption.SecurityOptions.UserPassword = "user";

saveOption.SecurityOptions.OwnerPassword = "owner";

saveOption.SecurityOptions.ExtractContentPermission = false;

saveOption.SecurityOptions.PrintPermission = false;

workbook.Save("test.pdf",saveOption);

Thanks!


Hi jaswinder,

This reply is only for your kind consideration. Please try our latest version Aspose.Cells v5.1.4:
http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry265124.aspx

The functionality of setting encryption and protection on pdf is now supported. Sample code is give below to use the settings.

Sample Code:
WorkBook objWb = new WorkBook("test.xls");
PdfSaveOptions saveOption = new PdfSaveOptions();
saveOption.SecurityOptions = new Rendering.PdfSecurity.PdfSecuritySettings();
saveOption.SecurityOptions.UserPassword = "user";
saveOption.SecurityOptions.OwnerPassword = "owner";
saveOption.SecurityOptions.ExtractContentPermission = false;
saveOption.SecurityOptions.PrintPermission = false;
objWb.Save("test.pdf",saveOption);

Thanks,