Rename Column Header

Hi,

I have a data table which is populated through to database object.
It has column names, for example Test123. I would like to import this data table to Excel sheet and also need to rename Test123 to Test 123.

I can do import using this code but how to rename column headers.
Can you please let me know.
<pre class=“code-java” style=“padding: 0px; margin-top: 0px; margin-bottom: 0px; overflow: auto; font-family: “Courier New”, Courier, monospace; line-height: 1.3; color: rgb(51, 51, 51); font-size: 12.0333px; background-color: rgb(255, 255, 255);”>Worksheet.Cells.ImportDataTable(dataTable, True, “A1”)


Thanks
Saurabh Shah
Hi,

Thanks for your query.

Well, I am afraid, there is not any option/parameter available (while importing data from a datatable) to rename column names. You can do it in the DataTable using your own .NET code either before importing data from DataTable via Aspose.Cells APIs. Alternatively, once the data is imported from the DataTable/DataSet into the worksheet, you can use Aspose.Cells APIs (e.g Cell.PutValue() method) to update the column header names by yourself.
If you are using first approach, kindly see the documents for your reference:
http://stackoverflow.com/questions/6407239/how-to-change-the-datatable-column-name
http://stackoverflow.com/questions/8924743/how-to-rename-the-datatable-column-name-without-losing-the-data

Thank you.

Great.

Thanks. PutValue function I was looking for.

Hi,


Good to know that it figure out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.