【发布时间】:2011-08-04 12:09:07
【问题描述】:
我知道如何写入单元格,但是如何将已写入 Excel 文件单元格中的现有字符串转换为字符串对象,以便我可以使用它在其他单元格中生成数据?
到目前为止我的代码:
Excel.ApplicationClass excelApp = new Excel.ApplicationClass();
excelApp.Visible = true;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open("C:\\Users\\user\\Desktop\\list.xls", 0, false, 5, "", "",
false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "Sheet1";
Excel.Worksheet xlws = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
我可以使用类似的东西来操作单元格内容:
xlws.Cells[1,1] = "foo";
但是我在做相反的事情时遇到了麻烦,即在我的程序中将单元格内容读入字符串。
任何帮助将不胜感激。
【问题讨论】: