Microsoft.Office.Interop.Excel.Application();
string filePath = Server.MapPath(@"~\\Staf\\TestLucene\\" + strFileName.ToString());
Microsoft.Office.Interop.Excel.Workbook workbook = application.Workbooks.Open(filePath, Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);
int numSheet = workbook.Sheets.Count;
for (int num = 1; num < numSheet + 1; num++)
{
Microsoft.Office.Interop.Excel.Worksheet sheet = (Worksheet)workbook.Worksheets[num];
Range excelRange = (Range) sheet.get_Range("A1", "H10");
object[,] valueArray = (object[,])excelRange.Value2;
for (int i = 1; i <= valueArray.GetLength(0); i++ )
{
for (int j = 1; j <= valueArray.GetLength(1); j++)
{
string text = Convert.ToString(valueArray[i, j]);
}
}
}
// Close word.
workbook.Close(false);
System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook);
application.Application.Quit();
|