我用来读取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!");
答案 0 :(得分:0)
WorkBook.Save()
是否可以保存excel文档'SaveAs()'。