0

我用来读取excel文件第一行的代码是这样的。如何在保存之前将该行保存在字符串变量中?以及如何保存excel文档?

string ExcelFile = Application.StartupPath + @"\SurveyLinks.xlsx";
Excel.Application ExcelApp = new Excel.Application();
Excel.Workbook ExcelWorkBook = ExcelApp.Workbooks.Open(ExcelFile);
Excel._Worksheet ExcelWorkSheet = ExcelWorkBook.Sheets[1];
Excel.Range ExcelRange = (Excel.Range)ExcelWorkSheet.Application.Rows[1, Type.Missing];
ExcelRange.Select();
//string SurveyLink = ExcelRange.Cells[1,1].Value2.ToString();
ExcelRange.Delete(Excel.XlDirection.xlUp);
ExcelWorkBook.Close(true);

ExcelApp.Quit();
MessageBox.Show(SurveyLink);
MessageBox.Show("Done!");
4

1 回答 1

0

WorkBook.Save()那里也可以保存 excel 文档“SaveAs()”。

于 2012-05-28T06:46:46.537 回答