Hidden columns are visible in PDF

Hello Team

When trying to convert Excel to PDF using aspose.cells for .NET , The hidden columns in the excel are also visible in the PDF. The hidden columns should not show in PDF.

Thanks

Rangaraj

Hi Rangaraj,


Thank you for contacting Aspose support.

Please share the sample spreadsheet along with it’s resultant PDF generated on your side. Please also provide the environment details as follow.

  • Operating System version & architecture
  • Operating System service pack version
  • .NET Framework version
  • Locale/Region of the machine
  • Aspose.Cells for .NET version

Hi Raza

Please find the below details

Operating System version & architecture: Windows server 2008 R2, 64 bit, service pack 1

.NET Framework version: 4.5

aspose.cells for .net 8.5.2.4

Hi Rangaraj,


Thank you for providing the environment details, however, we still need your sample spreadsheet and the resultant PDF file generated on your end to properly understand your presented scenario.

Please note, by default, the Aspose.Cells APIs render the spreadsheet in PDF format as the spreadsheet is displayed in the Print Preview of Excel application. It is the Excel’s standard not to render the hidden columns while rendering it to PDF format therefore Aspose.Cells APIs have the same behavior. Moreover, we have tested this case on one of our own samples while using the latest version of Aspose.Cells for .NET (Latest Version) (give it a try on your side as well), and we are not able to see the problem, that is; hidden columns do not render in PDF. Please review the attached spreadsheet, it’s resultant PDF and the code used for testing. Based on these observations we suspect that the problem could be sample specific therefore we need it for further investigation.

C#

Workbook book = new Workbook(“D:/book1.xlsx”);
book.Save(“D:/output.pdf”, SaveFormat.Pdf);

Hi Raza

Thanks for your reply

I have attached my excel for your reference. I still face the issue. In the print preview i dont see the hidden column but in pdf it is rendered.

Thanks

Rangaraj

Hi Rangaraj,


Thank you for the sample spreadsheet. We have evaluated the scenario against the latest version of Aspose.Cells for .NET (Latest Version) , and we are not able to see the problem in the resultant PDF file. Please check the attachment for the PDF, you will be able to notice that hidden column C is not rendered in it.

Have you tried the version of Aspose.Cells for .NET as suggested earlier in my response. If yes, please share it’s resultant PDF here for our review. Are you using different code for the conversion?

Hi Raza

Thanks for your reply

It Worked in the both the versions, the problem is that in my code i use sheet.Autofitcolumns(),when i comment that code the hidden column is not rendered in pdf. Is that autofitcolumns anything to do with it not sure.

Thanks

Rangaraj

Hi Rangaraj,


Yes, the AutoFitColumns method will increase the width of all the columns according to the size of data in corresponding cells. In case of the hidden columns, the width is set to 0 whereas after calling the AutoFitColumns method the width with increase to fit the data so the hidden columns will be rendered in the resultant PDF as well.