Excel Data to TreeView C#
I am looking to create a windows form that contains a tree view of data that I have in excel. I have the wi开发者_JAVA技巧ndows form I am just trying to figure out how to export the excel data into that data tree. Any links?
If you import Microsoft.Office.Interop.Excel
assembly you can access Excel files and use every property and method easily.
Example:
using Excel = Microsoft.Office.Interop.Excel;
public static object GetCellValue(
string filename, string sheet, int row, int column)
{
Excel.Application excel = new Excel.Application();
Excel.Workbook wb = excel.Open(filename);
Excel.Worksheet sh = wb.Sheets[sheet];
object ret = sh.Cells[row, column].Value2;
wb.Close();
excel.Quit();
}
精彩评论