public RptRoot() { Params = new RptParams(this); Data = new RptDataSource(this); PageSetting = new RptPageSetting(this); Header = new RptHeader(this); Body = new RptBody(this); Footer = new RptFooter(this); ViewSetting = new RptViewSetting(this); }
/// <summary> /// 序列化开始前,整理行高列宽,空行空列 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnBeforeSerialize(object sender, EventArgs e) { Worksheet ws = _excel.Sheets[0]; RptBody body = Info.Root.Body; // 列宽 int maxCol = body.ColSpan; int temp = Info.Root.Header.ColSpan; if (temp > maxCol) { maxCol = temp; } temp = Info.Root.Footer.ColSpan; if (temp > maxCol) { maxCol = temp; } double[] size = new double[maxCol]; for (int i = 0; i < maxCol; i++) { size[i] = ws.Columns[i].Width; } Info.Root.Cols = size; // 内容区域 int rowSpan = body.RowSpan; size = new double[rowSpan]; for (int i = 0; i < rowSpan; i++) { size[i] = ws.Rows[i].Height; } body.Rows = size; // 页眉 ws = _excel.Sheets[1]; Info.Root.Header.SetHeight(ws.Rows[0].Height); // 页脚 ws = _excel.Sheets[2]; Info.Root.Footer.SetHeight(ws.Rows[0].Height); }