Hi,
I can notice the issue as you have mentioned by using the following sample code.
Sample code:
Workbook wb = new Workbook();
Worksheet worksheet = wb.Worksheets[0];
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 3; j++)
{
worksheet.Cells[i, j].PutValue("Test: " + i.ToString() + “,” + j.ToString());
}
}
// Same order as the Excel sheet has
DataTable data = new DataTable();
data.Columns.Add(“Name”);
data.Columns.Add(“Num”);
data.Columns.Add(“Date”);
int[] cols = { 2 }; // changing this value does nothing
worksheet.Cells.ExportDataTable(data, 0, cols, 100, false);
Worksheet sheet2 = wb.Worksheets[wb.Worksheets.Add()];
sheet2.Cells.ImportDataTable(data, false, “A1”);
wb.Save(“e:\test2\output.xls”);
Note: the second sheet only displays the first column values.
I have logged a ticket with an id:CELLSNET-40894. We will look into it to figure it out soon.
By the way, if you need to get only one column in the data table, you may try:
Workbook wb = new Workbook();
Worksheet worksheet = wb.Worksheets[0];
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 3; j++)
{
worksheet.Cells[i, j].PutValue("Test: " + i.ToString() + “,” + j.ToString());
}
}
// Same order as the Excel sheet has
DataTable data = new DataTable();
data.Columns.Add(“Date”);
int cols = 2;
worksheet.Cells.ExportDataTable(data, 0, cols, 100, false);
Worksheet sheet2 = wb.Worksheets[wb.Worksheets.Add()];
sheet2.Cells.ImportDataTable(data, false, “A1”);
wb.Save(“e:\test2\outputcol.xls”);