示例#1
0
        private void 清除特殊线ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SpecialLine line = specialLineInfo.GetSpecialLine(sheet.ActiveCell);

            if (line != null)
            {
                sheet.ActiveCell.Tag = null;
                specialLineInfo.Remove(line);
                btn_save.Enabled = true;
            }
        }
示例#2
0
        private void Save()
        {
            List <ReportColumn> listReportColumn = new List <ReportColumn>();

            foreach (Column col in sheet.Columns)
            {
                if (col.Label.ToLower() == "rowgroup")
                {
                    continue;
                }
                ReportColumn reportColumn = report.Columns[col.Label];
                listReportColumn.Add(reportColumn);
            }
            report.Columns.Clear();
            foreach (ReportColumn reportColumn in listReportColumn)
            {
                report.Columns.Add(reportColumn);
            }

            report.Texts.Clear();
            report.Bands.ClearEchoDic();
            int index     = 0;
            int bandIndex = 0;
            int count     = 0;

            for (int i = 0; i < sheet.RowCount; i++)
            {
                if (sheet.Rows[i].Tag != null)
                {
                    count = 0;
                    switch (sheet.Rows[i].Tag.ToString())
                    {
                    case "标题":
                        bandIndex = 1;
                        index     = startHeadIndex;
                        break;

                    case "表头":
                        bandIndex = 2;
                        index     = startTitileIndex;
                        break;

                    case "表体":
                        bandIndex = 3;
                        index     = startBodyIndex;
                        break;

                    case "页汇":
                        bandIndex = 4;
                        index     = startPageIndex;
                        break;

                    case "表脚":
                        bandIndex = 5;
                        index     = startFootIndex;
                        break;
                    }
                    //初始化
                    report.Bands.SetBindRowNum(bandIndex, 0);
                    continue;
                }
                count++;
                if (sheet.Cells[i, sheet.ColumnCount - 1].Text != "True")
                {
                    report.Bands.SetBindRowEcho(bandIndex, i - index + 1, false);
                }
                report.Bands.SetBindRowNum(bandIndex, count);

                for (int j = 0; j < sheet.ColumnCount; j++)
                {
                    if (sheet.Cells[i, j].CellType is FarPoint.Win.Spread.CellType.CheckBoxCellType)
                    {
                        continue;
                    }
                    DataRow[] rows = dtSpan.Select(string.Format("{0} >= minY and {0} <= maxY and {1} >= minX and {1} <= maxX", i, j));
                    if (rows.Length == 0)
                    {
                        //不在合并单元格中
                        Text text = new Text();
                        text.BandIndex   = bandIndex;
                        text.Context     = sheet.Cells[i, j].Text;
                        text.Location.X1 = j + 1;
                        text.Location.Y1 = i + 1 - index;
                        text.Location.X2 = j + sheet.Cells[i, j].ColumnSpan;
                        text.Location.Y2 = i + sheet.Cells[i, j].RowSpan - index;

                        SpecialLine line = specialLineInfo.GetSpecialLine(sheet.Cells[i, j]);
                        if (line != null)
                        {
                            text.Attribute.Diagonal = line.LineType;
                        }

                        DesignHelper.SetTextPropertys(sheet.Cells[i, j], text);

                        report.Texts.Add(text);
                        DataRow row = dtSpan.NewRow();
                        row["minX"] = j;
                        row["minY"] = i;
                        row["maxX"] = j + sheet.Cells[i, j].ColumnSpan - 1;
                        row["maxY"] = i + sheet.Cells[i, j].RowSpan - 1;
                        dtSpan.Rows.Add(row);
                    }
                }
            }
            report.WriteRpt();
            dtSpan.Clear();
            btn_save.Enabled = false;
        }