i have an excel file that is grouped and i want to read data and write to my table .
this excel has the same value but in different path , and i have to write this data to a tree !!!
my question is: how i can read each row title(is a column ) and check this title if its new save in table , if its the same with another :check if this row parent >> parent>> parent is the same don’t insert
Thanks for your query.
I am not entirely certain about your requirements. Please provide a sample Excel file and complete details with some screenshots to highlight the task which you want to accomplish, we will check it soon.
thanks for answer
as you can see in my attached file I have a sheet that have several group of data ,
i have a root node and some data is child this node,(i have a tree in my app like this structure )
my excel file have 2 field extra from my tree and i want insert this two field in my db
as you can see for example i have 2 titlea with name: a3, but there parent is different ,
i have to know each row path (for example:a4>a2>a1) , if path is the same as tree write value to there table
thanks Untitled22.png (21.8 KB)
Thanks for the screenshot.
Well, you need to write your own code and logic to accomplish your task for your custom needs. You need to browse through the rows/columns and retrieve cells value for comparisons. I have written a simple code segment for your reference:
e.g
Sample code:
Workbook book = new Workbook("e:\\test2\\Book1.xlsx");
Worksheet sheet = book.Worksheets[0];
for (int i = 0; i <= sheet.Cells.MaxRow; i++)
{
int rowOutlineLevel = sheet.Cells.GetGroupedRowOutlineLevel(i);
if (rowOutlineLevel == 2) //second level
{
for (int j = 0; j <= sheet.Cells.MaxDataColumn; j++)
{
Console.WriteLine(sheet.Cells[rowOutlineLevel, j].StringValue);
}
break;
}
}
}
Hope, this helps a bit.
thanks for your answer
what is GetGroupedRowOutlineLevel()?
I want parent Id for each node, how to get it?
Well, Cells.GetGroupedRowOutlineLevel() method gives the outline level of the specified row. The method takes the row index as parameter. If the row is not grouped, it returns zero.