|
FileStream fileStream = new FileStream(DataPathBase + "Sample.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
IWorkbook workbook = application.Workbooks.Open(fileStream); |
Hi Ramya
Unfortunately the file is confidential and can't be shared.
I am aware of the memory being used in storing the data and just want to minimise memory use inside XLSIO objects.
Below I have added sample code. Note that we are using a MemoryStream not a FileStream.
ExcelEngine excelEngine = new ExcelEngine { ThrowNotSavedOnDestroy = false };
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2016;
// memStream is a memory stream containing the file bytes.
IWorkbook workbook = application.Workbooks.Open(memStream, ExcelOpenType.Automatic);
List<string> allData = new List<string>();
// SheetNames contains the names of each sheet in the workbook
foreach(string sheetName in sheetNames)
{
IWorksheet sourceSheet = inputWorkbook.Worksheets.Cast<IWorksheet>().FirstOrDefault(currentWorksheet => currentWorksheet.Name == sheetName);
IMigrantRange range = sourceSheet.MigrantRange;
for (int col = 1; col < lastColumn + 1; col++)
{
for (int row = 1; row < lastRow + 1; row++)
{
range.ResetRowColumn(row, col);
string value = range.Value;
allData.Add(value);
}
}
}
Regards,
Malachy
Hi Ramya
Please ignore how the data is held in the sample code. I am seeing high memory usage inside XLSIO objects. How the data is stored outside XLSIO is not relevant to this issue.
Regards,
Malachy