I am looking to create a windows form that contains a tree view of data that I have in excel. I have the windows form I am just trying to figure out how to export the excel data into that data tree. Any links?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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();
}