Невозбранно потырил с http://blog.logiclabz.com/asp-net/reading-writing-data-from-excel-in-asp-net-2-0.aspx
- using Microsoft.Office.Interop.Excel;
- // Creates a new Excel Application Object
- ApplicationClass xlsApp = new ApplicationClass();
- try
- {
- //Opens WorkBook in Excel
- WorkbookClass xlsWrkBook=(WorkbookClass)xlsApp.Workbooks.Open
- ("c:\\1.xls", 0, false, 5, "", "", true,
- XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
- //Gets the sheet 1 of the opened workbook
- Worksheet xlsWrkSht = (Worksheet)xlsWrkBook.Worksheets.get_Item(1);
- //Gets Cell 1st Row and 1st Column. Desired can be given
- Range ExcelCellText = (Range)xlsWrkSht.Cells[1, 1];
- // Reads Data of selected cell
- string str = ExcelCellText.Text.ToString();
- // Writes Data of selected cell
- ExcelCellText.Value2 = "Sample Write";
- xlsWrkBook.Save();
- xlsWrkBook.Close(0, 0, 0);
- }
- catch
- { }
- finally
- {
- xlsApp = null;
- }
Комментариев нет:
Отправить комментарий