Free Support Forum - aspose.com

Cells.ImportDataTable Question

Hello,

I am using the Cells.ImportDataTable function to import data into my spreadsheet… I noticed that there was an input parameter called “isFieldNameShown”… When I set it to “True”, it only shows the fields names if the data table I am trying to import has 1 or more rows… I would prefer the column names to be displayed regardless… Is there any way to do this???

Thanks,

-Dana

Dear Dana,

Aspose.Excel will support this feature in next hotfix. Thanks for your patience.

Now you can try this workaround.

if(dt.Rows.Count == 0)
{
for(int i = 0; i < dt.Columns.Count; i ++)
{
string columnName = dt.Columns[i].ColumnName;
cells[0, i].PutValue(columnName);
}
}
else
{
cells.ImportDataTable(…);
}

Thanks a lot…

I really appreciate you guys making an effort to upgrade your product…

-Dana