Hi
How can one specify the whole of the wooksheet rather than just
7 rows and 2 columns
worksheet.Cells.ExportDataTableAsString(0,0,7,2,true);
thanks
Hi
How can one specify the whole of the wooksheet rather than just
7 rows and 2 columns
worksheet.Cells.ExportDataTableAsString(0,0,7,2,true);
thanks
I added this
DataTable dataTable = worksheet.Cells.ExportDataTableAsString(0, 0, worksheet.Cells.MaxRow + 1, worksheet.Cells.MaxColumn + 1);
but it insert colum1, column2 on top of the orginal columns
thanks
How many columns of data in your Excel file? Is it possible that first 2 columns are hidden? Please post your sample file here.
I have about 49 rows. But this always varies according to the user's excel file.
What I am after is a way to let the code select all the rows and columns.
this is the closet i have found
DataTable dataTable = worksheet.Cells.ExportDataTableAsString(0, 0, worksheet.Cells.MaxRow + 1, worksheet.Cells.MaxColumn + 1);
public void ExcelCell()
{
Workbook workbook = new Workbook();
//workbook.Open(strFileName);
workbook.Open(FileToUpload.PostedFile.InputStream);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Exporting the contents of 7 rows and 2 columns starting from 1st cell to DataTable
DataTable dataTable = worksheet.Cells.ExportDataTableAsString(0,0,49,41,true);
//DataTable dataTable = worksheet.Cells.ExportDataTableAsString(0, 0, worksheet.Cells.MaxRow + 1, worksheet.Cells.MaxColumn + 1);
//Binding the DataTable with DataGrid
DataGrid1.DataSource = dataTable;
DataGrid1.DataBind();
Please try:
DataGrid1.DataSource = dataTable;
DataGrid1.ShowHeader = false;
DataGrid1.DataBind();