Convert CSV to PDF and render comma using C#

I’m wonderring if ASPPOSE.cells support csv to pdf convert? I do a testing but the comma lost in pdf,how to handle it?

Hi,


Thanks for your posting and using Aspose.Cells.

Comma is considered a Separator character. Therefore, it is lost when you load it inside Workbook object and render it to Pdf. But if you want to keep Comma in Pdf rendering, then set the Separator to something else.

The following code loads the sample CSV file inside the Workbook object but not with Comma as a separator and then render it to output Pdf which also shows commas as per your requirement.

Besides, we have tested with the recent version that it is not losing comma if the comma is within the contents of cells (e.g. if cell has some value like “This,comma”, it will be rendered fine in Pdf).

Latest Version Links

Aspose.Cells for .NET (Latest Version)


C#
TxtLoadOptions txtOpts = new TxtLoadOptions();
txtOpts.SeparatorString = "@XP@";

Workbook wb = new Workbook("sampleCSVFile.csv", txtOpts);
wb.Save("outputCSV.pdf");

I use aspose.word for .net implement that, not sure if it still supports that feature. how do you think about it?

Hi,


Thanks for your posting and considering Aspose APIs.

We are afraid, Aspose.Words works with Microsoft Word documents and that does not include CSV file. CSV file is actually related to Microsoft Excel and Aspose.Cells deals with Microsoft Excel documents.

Thanks for the answer, do you know if I can talk about the product purchase things in here, I also want to know more details about product and service support things. And also, do you konw how long will take if I want to purchase the product.

Hi,


Thanks for considering Aspose.Cells.

Since, we are technical support members, we do not have precise information relating to purchase or sales stuff. Besides, we cannot share with you any incorrect information, nor it will benefit you but might create problems for you. Therefore, we request you to post only technical related queries here and for purchase or sales queries, please post in Aspose.Purchase forum. Aspose.Purchase team will guide you better in this regard. Thanks for your understanding and have a good day.

I do testing with txtOpts.SeparatorString = “@XP@”; today, it indeed separated with comma, but why I couldn’t set it looks like


txtOpts.SeparatorString = ","

why I couldn’t use “,” directly, what’s the setting rules for the SeparatorString? I feel a little confused about it

Hi,


Thanks for using Aspose.Cells.

You can load CSV file directly or using TxtLoadOptions. TxtLoadOptions by default use Comma as a separator. Even then you can specify comma as a separator using Separator or SeparatorString properties.

Please see the following code for more help. I have attached the output CSV files for your reference.

C#
//Case - I
Workbook wb1 = new Workbook(“sampleCSVFile.csv”);
wb1.Save(“1_CSV-Direct.pdf”);

//Case - II
TxtLoadOptions opts2 = new TxtLoadOptions();
Workbook wb2 = new Workbook(“sampleCSVFile.csv”, opts2);
wb2.Save(“2_CSV-TxtLoadOptions.pdf”);

//Case - III
TxtLoadOptions opts3 = new TxtLoadOptions();
opts3.Separator = ‘,’;
Workbook wb3 = new Workbook(“sampleCSVFile.csv”, opts3);
wb3.Save(“3_CSV-TxtLoadOptions-Separtor-Comma.pdf”);

//Case - IV
TxtLoadOptions opts4 = new TxtLoadOptions();
opts4.SeparatorString = “,”;
Workbook wb4 = new Workbook(“sampleCSVFile.csv”, opts4);
wb4.Save(“4_CSV-TxtLoadOptions-SeparatorString-Comma.pdf”);

okay, that’s really cool