2012-05-28 110 views
0

我用來讀取excel文件第一行的代碼是這樣的。如何在保存之前將該行保存在字符串變量中?以及如何保存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

任何人.............. ?? – aroshlakshan

回答

0

WorkBook.Save()有保存Excel文檔 '另存爲()' 也可以有。