XLService.ExcelService objXL1 = new ExcelService(); ExcelService objXL = new ExcelService(); objXL.Url = "http://serverName:port/_vti_bin/excelservice.asmx"; objXL.PreAuthenticate = false; objXL.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; XLService.Status[] stat1; XLService.Status[] stat2; string sessionId = string.Empty; StringBuilder sbResult = new StringBuilder(); sessionId = objXL.OpenWorkbook(strFileUrl, String.Empty, String.Empty, out stat1); object[] sheetNames = objXL.GetSheetNames(sessionId, out stat2); foreach (object[] sheetName in sheetNames) { for (int iCount = 0; iCount < sheetName.Length; iCount++) { strSheetName = Convert.ToString(sheetName[iCount]); // retrieve the range as an array of arrays object[] rangeResults = objXL.GetRangeA1(sessionId, strSheetName, "A1:F10", true, out stat1); foreach (object[] rangeResult in rangeResults) { for (int iIndex = 0; iIndex < rangeResult.Length; iIndex++) { sbResult.Append(Convert.ToString(rangeResult[iIndex])); } } objXL.CloseWorkbook(sessionId); } }
UsedRange
get_range()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)