We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

CSV to pdf data Loss

Hello
i am converting csv to pdf by below code

TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.CSV);
loadOptions.setCheckExcelRestriction(false);
Workbook book = new Workbook(Filename,loadOptions);
book.getWorksheets().get(0).autoFitColumns();
pageSetup.setOrientation(PageOrientationType.LANDSCAPE);
book.save(Pathdata + File.separator + Fname + “.pdf”, SaveFormat.PDF);

but data should be loss in output pdf file
so please look into this
i also attached file and screen shot of data loss.
cell issue.zip (4.0 MB)

Thanks

@David_jack,

These are not the issue(s) with the APIs rather the issues are due to the line of code:

     book.getWorksheets().get(0).autoFitColumns();
    pageSetup.setOrientation(PageOrientationType.LANDSCAPE);

Please perform the task in Ms Excel manually, i.e., open the CSV file into MS Excel and then select each column (one by one) and perform auto-fit column operation. Now open Page Setup dialog and set “Landscape” orientation. Now take the print preview of the sheet and you will notice your mentioned issues. You can even save as “PDF” in MS Excel manually to get similar output PDF. Please note, Aspose.Cells follows MS Excel standards and specifications while rendering to PDF file format.

@David_jack

The head of Column 3 is “Area_description”, it is acutally in the output pdf. see my screenshot Screenshot_head.png (58.5 KB)

For your “Screenshot (26).png” highlighted, you can save your csv file to a xlsx file before saving to pdf, then open the output xlsx file, check Page 140725 in Microsoft Excel printview, you will get the same result.

@Peyton.Xu
Please look a file , every alternate pages added an extra blank page which is unnecessary .so can i know the reason? or can it fix?
i used the above code in this thread .
i have attached input file , output file(PageOrientationType.PORTRAIT) , and a pdf (generated by excel auto fit and portrait view ) with issue screen shots.
issue 2.zip (626.4 KB)
thanks

@David_jack

You can open your csv file in a text editor, you can see there are three blank lines at the end, especially there is a space(Cell B55 when you open csv in Excel), and it is output to pdf. See my screenshot: Screenshot_blankline.png (8.1 KB)