Hi,
How to identify from which cell the information is available in a worksheet.
Ex: In my xls file first and second row is blank. the data starts from D3, D4,D5,…
and in other xls file the data may start from B2, B3, B4…
So how could I find from which cell the data started in a worksheet?
Thanks,
Hi,
You may try Cell.MinRow and Cells.MinColumn attributes:
e.g
Workbook wb = new Workbook(@“e:\test\Book1.xlsx”);
Cells cells = wb.Worksheets[0].Cells;
MessageBox.Show("Min row: " + cells.MinRow.ToString());
MessageBox.Show("Min column: " + cells.MinColumn.ToString());
Thank you.
Hi there,
Thanks for your response. cells.MinRow and cells.MinColumn is always giving 1 and 0.
<!–[if gte mso 10]>
/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} table.MsoTableGrid {mso-style-name:"Table Grid"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; border:solid windowtext 1.0pt; mso-border-alt:solid windowtext .5pt; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-border-insideh:.5pt solid windowtext; mso-border-insidev:.5pt solid windowtext; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}<![endif]–>
|
A |
B |
C |
D |
E |
1 |
|
|
|
|
|
2 |
|
|
City |
Dhuli |
Europe |
3 |
|
|
Italy |
Ship |
Hasfa |
4 |
|
|
Delhi |
Core |
Scope |
5 |
|
|
Vizag |
Thing |
justa |
In my xsl A1,A2,B1,B2,C1 are blank. Information was available form C2 only. In some other xls file data may available from D4.
So how can I identify from which row and column, data is available(like C2)? In my given example I need to get row as 2 and column as C.
Thanks,
Hi,
"cells.MinRow and cells.MinColumn is always giving 1 and 0."
Well, 1 means second row which is right and 0 means first column which is not right. We will check if we can fix it for Cells.MinColumn attribute.
I think you may try the following sample code to get the first cell that has data in it.
e.g
Workbook wb = new Workbook(@“e:\test\Book1.xlsx”);
Cells cells = wb.Worksheets[0].Cells;
bool chk = false;
for (int i = 0; i <= wb.Worksheets[0].Cells.MaxRow; i++)
{
for (int j = 0; j <= wb.Worksheets[0].Cells.MaxColumn; j++)
{
if (wb.Worksheets[0].Cells[i, j].Type == CellValueType.IsNull)
{
continue;
}
else {
MessageBox.Show(“First cell contains data:” + wb.Worksheets[0].Cells[i, j].Name);
chk = true;
break;
}
}
if (chk)
{ break; }
}
Thank you.