How to access first cell in table

Hi,

I am creating 3 headers on the excel, want to access the immediate next row 1st cell so that I can start populating the data from data table.

For example, 2 headers (First Name - A1, Last Name - B1) and I can write a programm to start populating the the data from cell A2 or A3.

However, I need to write programm to get this immediate A2 cell (after A1) where from I can populate the data.

Is there any property in Aspose.Cell which automatically return the next cell in the column?

Thanks

Hi,

You should find the cell
containing the data e.g “FirstName” first, then get the row of that cell,
you may add number of rows to that cell to get your start index for
filling the data table and finally, import the data table starting at
your desired position in the sheet.

Here is the sample code if it helps you implement your desired task. I have also attached the input file here.

Sample code:

DataTable dt = new DataTable(“Customers”);
dt.Columns.Add(“C_FName”);
dt.Columns.Add(“C_LName”);
dt.Columns.Add(“C_Age”, typeof(decimal));
DataRow dr = dt.NewRow();
dr[“C_FName”] = “Richard”;
dr[“C_LName”] = “Milton”;
dr[“C_Age”] = 45;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[“C_FName”] = “Micheal”;
dr[“C_LName”] = “Dowdan”;
dr[“C_Age”] = 41;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[“C_FName”] = “ABC”;
dr[“C_LName”] = “DEF”;
dr[“C_Age”] = 39;
dt.Rows.Add(dr);

Workbook workbook = new Workbook();
workbook.Open(@“e:\test\MySpecificBook.xls”);
Worksheet worksheet = workbook.Worksheets[0];

//Search the “FirstName” cell in the first sheet.
Aspose.Cells.Cell fcell = worksheet.Cells.FindString(“FirstName”, null);

//Populate the data starting from the row next to the “FirstName” cell in the same column.
worksheet.Cells.ImportDataTable(dt, false, fcell.Row +1,fcell.Column);

workbook.Save(“e:\test\out_MySpecificBook.xls”);


Thank you.