我希望创建一个包含我在excel中拥有的数据树视图的窗口表单。我有窗口的形式,我只是想弄清楚如何导出excel数据到该数据树。有链接吗?
如果您导入Microsoft.Office.Interop.Excel
程序集,您可以访问Excel文件并轻松使用每个属性和方法。
例子:
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();
}