Importing CSV with Aspose.Cells

Hi All,

We are using Aspose.cells.dll ver 4.4.0.5 and we are trying to import csv data

into our database with it. It is working correctly except for leading zeroes for

a string datatype where it is truncating the leading zeroes off the value when

it is coming into the database.

We tried using the property of ConvertNumericData like wb.ConvertNumericData = false;

also but that did not work. Could you help us in getting over this issue?

Do we need to look at converting the column of the excel workbook to string type

before trying to import the value? Will it work that way?

Thanks,

Aninda


This message was posted using Email2Forum by ShL77.

Hi Aninda,

Thank you for considering Aspose product.

You have to use Stlye.NumberFormat Enumeration. Please follow the links below for details:

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-display-formats-of-numbers-dates.html

You may see the following video tutorials too:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/set-display-formats-of-numbers-and-dates.html

You can also check the demo too:

Code snippet:

Workbook workbook = new Workbook();
workbook.ChangePalette(System.Drawing.Color.SkyBlue, 55);
Worksheet worksheet = workbook.Worksheets[0];
Style style = worksheet.Cells["A1"].GetStyle();
style.Number = 49;
worksheet.Cells["A1"].SetStyle(style);
worksheet.Cells["A1"].PutValue(86113371280692223);
workbook.Save("C:\\cellBGtest.xls", SaveFormat.Excel97To2003);
workbook.Save("C:\\cellBGtest.xlsx", SaveFormat.Xlsx);
/////////////////////////////////////////////////////////////////////////////////////////////////////////

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Style style = worksheet.Cells["A1"].GetStyle();
style.Custom = "00000000000000000";
worksheet.Cells["A1"].SetStyle(style);
worksheet.Cells["A1"].PutValue(86113371280692223);
workbook.Save("e:\\test\\cellBGtest.xlsx", SaveFormat.Xlsx);

Thanks,