protected virtual object[,] _ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo) { int rows = rangeInfo.EndRow - rangeInfo.StartRow + 1; int cols = rangeInfo.EndColumn - rangeInfo.StartColumn + 1; int[] lowerBounds = new int[] { 1, 1 }; int[] lengths = new int[] { rows, cols }; object[,] values = (object[, ])Array.CreateInstance(typeof(object), lengths, lowerBounds); int totalRows = rows; int row = rangeInfo.StartRow; int count = 1; if (o != null) { o.InitializeProgress(1, totalRows); } for (int i = values.GetLowerBound(0); i <= values.GetUpperBound(0); i++) { if (o != null && o.ExecutorService.IsShutdown) { break; } int col = rangeInfo.StartColumn; for (int j = values.GetLowerBound(1); j <= values.GetUpperBound(1); j++) { values[i, j] = this.Cell(row, col).Value; if (o != null) { Thread.Sleep(1); } col++; } if (o != null) { int proPerc = (int)(((float)(i) / (float)totalRows) * 100.0); o.UpdateStatusProgress((count), "Reading value from excel . . . : " + (count) + " of " + totalRows.ToString() + " (" + proPerc + "%)"); } row++; count++; if (o != null) { Thread.Sleep(1); } } return(values); }
public bool Write(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Write"); bool result = default(bool); try { result = this.WriteInternal(o, values, rangeInfo); } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
protected virtual bool _WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo) { int totalRows = values.GetUpperBound(0) + 1; int row = rangeInfo.StartRow; int count = 1; if (o != null) { o.InitializeProgress(1, totalRows); } for (int i = values.GetLowerBound(0); i <= values.GetUpperBound(0); i++) { if (o != null && o.ExecutorService.IsShutdown) { break; } int col = rangeInfo.StartColumn; for (int j = values.GetLowerBound(1); j <= values.GetUpperBound(1); j++) { this.Cell(row, col).Value = values[i, j].ToString(); if (o != null) { Thread.Sleep(1); } col++; } if (o != null) { int proPerc = (int)(((float)(i) / (float)totalRows) * 100.0); o.UpdateStatusProgress((count), "Writing value to excel . . . : " + (count) + " of " + totalRows.ToString() + " (" + proPerc + "%)"); } row++; count++; if (o != null) { Thread.Sleep(1); } } return(true); }
public object[,] Read(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "Read"); object[,] result = default(object[, ]); try { result = this.ReadInternal(o, rangeInfo); } catch (Exception ex) { Log.Exception(PROC, ex); } return(result); }
protected abstract bool WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo);
protected abstract object[,] ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo);
public abstract void AutoResizeColumns(ExternalExcelRangeInfo rangeInfo);
public override void AutoResizeColumns(ExternalExcelRangeInfo rangeInfo) { }
protected override bool WriteInternal(IAsyncProgress2 o, object[,] values, ExternalExcelRangeInfo rangeInfo) { return(this._WriteInternal(o, values, rangeInfo)); }
protected override object[,] ReadInternal(IAsyncProgress2 o, ExternalExcelRangeInfo rangeInfo) { return(this._ReadInternal(o, rangeInfo)); }