Esempio n. 1
0
        /// <summary>
        /// 输出表数据
        /// </summary>
        /// <param name="dt">DataTable对称</param>
        /// <param name="xlExport">ReportExportToExcel对象</param>
        private static void _WriteBody(DataTable dt, ReportExportToExcel xlExport)
        {
            int headerRows = 2;

            //插入数据集报表数据
            xlExport.DataTableToExcel(dt, 1, 1, dt.Rows.Count, 5, headerRows + 1, 1);
            //设置数报表数据单元格为文本形式
            Range range = xlExport.GetRange(headerRows + 1, 1, dt.Rows.Count + headerRows + 1, 5);

            xlExport.SetTextForm(range);
            //设置行高
            xlExport.SetRowHeight(headerRows + 1, headerRows + dt.Rows.Count + 1, 14);
            //设置数据集报表数据对齐方式(行3,列1,行末,列5)
            range = xlExport.GetRange(headerRows + 1, 1, dt.Rows.Count + headerRows, 5);
            xlExport.SetCellsAlignment(range, ExcelHorizontalAlignment.Center);
            //设置报表数据边框
            xlExport.SetAllCellsBorderExclusiveRLTB(headerRows + 1, 1, dt.Rows.Count + headerRows, 5, ExcelBorderWeight.Thin);
        }
Esempio n. 2
0
        /// <summary>
        /// 输出表数据
        /// </summary>
        /// <param name="dt">DataTable对称</param>
        /// <param name="xlExport">ReportExportToExcel对象</param>
        private static void _WriteBody(DataTable dt, ReportExportToExcel xlExport)
        {
            //数据集报表数据
            string[] colNameSet = new string[]
            { "B", "L", "D", "C", "E", "F", "I", "J",
              "N", "G", "H", "M", };

            int headerRows = 2;

            //插入数据集报表数据
            xlExport.DataTableToExcel(dt, colNameSet, headerRows + 1, 1);
            //设置数报表数据单元格为文本形式
            Range range = xlExport.GetRange(headerRows + 1, 1, dt.Rows.Count + headerRows + 1, 12);

            xlExport.SetTextForm(range);
            //设置行高
            xlExport.SetRowHeight(headerRows + 1, headerRows + dt.Rows.Count + 1, 14);
            //设置数据集报表数据对齐方式(行3,列1,行末,列12)
            range = xlExport.GetRange(headerRows + 1, 1, dt.Rows.Count + headerRows, 12);
            xlExport.SetCellsAlignment(range, ExcelHorizontalAlignment.Center);
            //设置报表数据边框
            xlExport.SetAllCellsBorderExclusiveRLTB(headerRows + 1, 1, dt.Rows.Count + headerRows, 12, ExcelBorderWeight.Thin);
        }