Is Spire.XLS C# support HDR - option when Excel file has no header file?

605 Views Asked by At

Is Spire.XLS C# support HDR - option when Excel file has no header file ? I have Excel file without header file. This is resolved in OLEDB driver in connection string HDR="No" Option.

1

There are 1 best solutions below

0
Dheeraj Malik On

You can use the ExportDataTable(CellRange range, bool exportColumnNames) method of Spire.Xls.Worksheet class to read worksheet data into a data table and determine whether to export the first row in the worksheet range as header row in the data table.

Example:

private void button1_Click(object sender, EventArgs e)
{
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("Input.xlsx");
    Worksheet sheet = workbook.Worksheets[0];
    DataTable dt = sheet.ExportDataTable(sheet.Range, false);
    dataGridView1.DataSource = dt;
}

enter image description here