Hi
When I am create a Worksheet class object over a CSV file and trying to export its data into a DataTable and my CSV file has some special characters then it is not exporting those characters in dataTable. And more intresting part is that after export it put white space instead of of those special characters.
I have attached the CSV file for reference.
Here is my code:
Workbook workbook = new Workbook(file.FullName);
if (workbook != null && workbook.Worksheets.Count > 0)
{
Worksheet worksheet = workbook.Worksheets[0];
if (worksheet.Cells.MaxColumn > -1 && worksheet.Cells.MaxDataRow > -1)
{
worksheet.Cells.DeleteBlankColumns();
DataTable dt = new DataTable();
dt.Columns.Add("rbid", typeof(String));
dt.Columns.Add("rulebook_name", typeof(String));
dt.Columns.Add("record_id", typeof(String));
dt.Columns.Add("element_id", typeof(String));
dt.Columns.Add("parent", typeof(String));
dt.Columns.Add("breadstring", typeof(String));
dt.Columns.Add("parent_title", typeof(String));
dt.Columns.Add("peer_order", typeof(String));
dt.Columns.Add("start_date", typeof(String));
dt.Columns.Add("end_date", typeof(String));
dt.Columns.Add("rule_number", typeof(String));
dt.Columns.Add("title", typeof(String));
dt.Columns.Add("url", typeof(String));
int[] colCount = new int[worksheet.Cells.MaxDataColumn + 1];
colCount[0] = 0;
colCount[1] = 1;
colCount[2] = 2;
colCount[3] = 3;
colCount[4] = 4;
colCount[5] = 5;
colCount[6] = 6;
colCount[7] = 7;
colCount[8] = 8;
colCount[9] = 9;
colCount[10] = 10;
colCount[11] = 11;
colCount[12] = 12;
worksheet.Cells.ExportDataTable(dt, worksheet.Cells.MinRow + 1, colCount, worksheet.Cells.MaxDataRow + 1, false, true);
if (dt != null && dt.Rows.Count > 0)
{
ruleTables.Add(dt);
}
}
}