1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Microsoft.Office.Interop.Excel.Application xlApp;
Workbook xlWorkBook;
Worksheet xlWorkSheet;
Range range;
string str;
int rCnt; //ligne courante
int cCnt; //colonne courante
int rw = 0; //nb de lignes
int cl = 0; //nb de colonnes
xlApp = new Microsoft.Office.Interop.Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(@"C:\Users\P1064\Documents\MATLAB\Simulation\VariableExcel", 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);
range = xlWorkSheet.UsedRange;
rw = range.Rows.Count;
cl = range.Columns.Count;
range.Cells[3, 2].Value2 = 12;
double val = range.Cells[3, 2].Value2;
MessageBox.Show((range.Cells[3, 2].Value2).ToString());
xlWorkBook.Close(true, null, null);
xlApp.Quit();
Marshal.ReleaseComObject(xlWorkSheet);
Marshal.ReleaseComObject(xlWorkBook);
Marshal.ReleaseComObject(xlApp); |
Partager