Ejemplo n.º 1
0
    public CXLRootGroup(CXLRDataSet pOwner, Excel.Range pDSRange) : base(pOwner, null, 0) {
      this.GRTTmplDef = new CXLRTemplateDef(pDSRange);
      try {
        this.FHeaderFormatsCount = this.GRTTmplDef.HeaderFormats.Count;
        this.FLeftColOffset = pDSRange.Column;
        this.FTopRowOffset = pDSRange.Row;
        this.FColDefs = new CXLRColDefs();
        this.FLeftCol = 1;
        this.FTopRow = 1;
        this.parsColumns();
        this.GRTTmplDef.Check(this);
        if (this.ColDefs.HasTotals)
          this.FTotals = new CXLRTotals(this);
        this.FGroupFieldNamesComma = this.getGroupFieldNamesComma();

      } finally {
        this.GRTTmplDef.Dispose();
        this.GRTTmplDef = null;
      }
		}
Ejemplo n.º 2
0
    public void BuildReport(Excel.Range dsRange) {
       var ownerRptDef = this.Owner.Owner.Owner.RptDefinition;
      this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : Старт...");

      this.GRTTmplDef = new CXLRTemplateDef(dsRange);
      this.FLeftColOffset = dsRange.Column;
      this.FTopRowOffset = dsRange.Row;
      try {
        this.FHeaderFormatsCount = this.GRTTmplDef.HeaderFormats.Count;
        this.FIsGroupDefined = this.FHeaderFormatsCount > 0;
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : this.insertRows(" + this.RowsCount + ")...");
        Boolean additionalRowInserted = (this.RowsCount == 1);
        this.insertRows(additionalRowInserted ? 2 : this.RowsCount);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : this.insertRows(" + this.RowsCount + ") - OK.");
        //return;
        Object[,] vBuffer = new Object[this.RowsCount, this.ColDefs.Count];
        this.FCurBufferRowIndex = -1;
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : FillBuffer...");
        this.FillBuffer(dsRange.Worksheet, vBuffer);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : FillBuffer - OK.");
        //throw new Exception("Test!!!");
        Excel.Range vInsRng = ExcelSrv.getRange(this.GRTTmplDef.DetailsRng.Worksheet,
                              this.GRTTmplDef.DetailsRng.Cells[1, 1],
                              this.GRTTmplDef.DetailsRng.Cells[this.GRTTmplDef.DetailsRng.Rows.Count, this.GRTTmplDef.DetailsRng.Columns.Count]);
        if (ownerRptDef.DebugIsOn) {
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveBufferToTxt...");
          this.saveBufferToTxt(vBuffer, false);
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveBufferToTxt - OK.");
        }
        try {
          String insRngCoord = vInsRng.Address;
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : vInsRng["+insRngCoord+"].Formula = vBuffer...");
          //vInsRng.CopyFromRecordset(vBuffer);

          if (ownerRptDef.DebugIsOn) {
            this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveGroupTree...");
            this.RootGroup.GetXmlDoc().Save(ownerRptDef.LogPath + ownerRptDef.ShortCode + ".DS_DATA." + this.FOwner.Owner.Cfg.rangeName + "_pre.xml");
            this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : saveGroupTree - OK.");
          }

          vInsRng.FormulaLocal = vBuffer;
          if (this.Owner.PrepareDataError != null) {
            Excel.Range vInsErrRng = ExcelSrv.getRange(this.GRTTmplDef.DetailsRng.Worksheet,
                                  this.GRTTmplDef.DetailsRng.Cells[this.GRTTmplDef.DetailsRng.Rows.Count+1, 1],
                                  this.GRTTmplDef.DetailsRng.Cells[this.GRTTmplDef.DetailsRng.Rows.Count+1, 1]);
            vInsErrRng.FormulaLocal = this.Owner.PrepareDataError.Message;
            vInsErrRng.Font.Color = ConsoleColor.Red;
          }
          this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : vInsRng.Formula = vBuffer - OK.");
        } catch (Exception ex) {
          if (!ownerRptDef.DebugIsOn) 
            this.saveBufferToTxt(vBuffer, true);
          throw new EBioException("Ошибка при вставке буфера. vInsRng.Length:(" + vInsRng.Rows.Count + "," + vInsRng.Columns.Count + "); vBuffer.Length:(" + vBuffer.GetLength(0) + "," + vBuffer.GetLength(1) + "); msg:" + ex.ToString(), ex);
        }
        Excel.Range vDelLast = (Excel.Range)this.GRTTmplDef.DetailsRng.Rows[this.GRTTmplDef.DetailsRng.Rows.Count, Type.Missing];
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : refreshFormulaCols...");
        this.refreshFormulaCols(vDelLast);
        this.RefreshTTLFormula(dsRange);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : refreshFormulaCols - OK.");

        vDelLast.Delete(Type.Missing);
        if (additionalRowInserted) {
          vDelLast = (Excel.Range)this.GRTTmplDef.DetailsRng.Rows[this.GRTTmplDef.DetailsRng.Rows.Count, Type.Missing];
          vDelLast.Delete(Type.Missing);
        }
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : AppliayFormat...");
        this.AppliayFormat(dsRange);

        if (this.FIsGroupDefined)
          this.GroupChild(dsRange.Worksheet);
        this.Owner.Owner.Owner.writeLogLine("\tbldr:root-grp:(" + this.Owner.Owner.Cfg.alias + ") : AppliayFormat - OK.");

      } finally {
        this.GRTTmplDef.Dispose();
        this.GRTTmplDef = null;
      }
    }