private void DoPreload(TBand aParentBand, string aRange, string aFileName, TDataSourceInfoList aDsInfoList, int aNestedLevel, ExcelFile Result, MemoryStream MStream, FlexCelReport aParentReport) { Result.Open(MStream); Result.ActiveFileName = aFileName; TXlsNamedRange XlsRange = Result.GetNamedRange(aRange, -1); if (XlsRange == null) { FlxMessages.ThrowException(FlxErr.ErrCantFindNamedRange, aRange); } FRangeName = aRange; MainBand = CreateStartingBand(XlsRange, aParentBand, aRange); Report = new FlexCelReport(aNestedLevel, FTagText, aDsInfoList, aParentReport); if (!StaticInclude) { Report.PreLoad(Result, ref MainBand, XlsRange.SheetIndex, ref FData, out KeepRows, out KeepCols); } Result.ActiveSheet = XlsRange.SheetIndex; }
internal TInclude(byte[] aData, string aRange, TBandType aBandType, TBand aParentBand, string aTagText, int aNestedLevel, TDataSourceInfoList aDsInfoList, string aFileName, bool aStaticInclude, FlexCelReport aParentReport) { try { FData = new byte[aData.Length]; Array.Copy(aData, 0, FData, 0, FData.Length); FBandType = aBandType; FTagText = aTagText; StaticInclude = aStaticInclude; //Preloading at read time has the advantage of fully checking the template on load, //so errors will be detected sooner. (If an include is conditional, might not be detected until much later) //For this same reason it is a little slower than preloading on demand, but it is worth. Preload(aParentBand, aRange, aFileName, aDsInfoList, aNestedLevel, aParentReport); } catch { Dispose(); throw; } }
private void Preload(TBand aParentBand, string aRange, string aFileName, TDataSourceInfoList aDsInfoList, int aNestedLevel, FlexCelReport aParentReport) { ExcelFile Result = new XlsAdapter.XlsFile(); using (MemoryStream MStream = new MemoryStream(FData)) { MStream.Position = 0; if (aNestedLevel > 1) { DoPreload(aParentBand, aRange, aFileName, aDsInfoList, aNestedLevel, Result, MStream, aParentReport); } else { try //We only catch a level 1 include. if not, we would end up with a nested message. { DoPreload(aParentBand, aRange, aFileName, aDsInfoList, aNestedLevel, Result, MStream, aParentReport); } catch (Exception e) { FlxMessages.ThrowException(e, FlxErr.ErrOnIncludeReport, FTagText, e.Message); } } } }