Beispiel #1
0
        private void footerPrint(ExcelXmlParser parser)
        {
            cols = parser.getColumnsInfo("foot");
            ExcelBorder border = getBorder();

            if (parser.getWithoutHeader() == false)
            {
                ExcelFont font = wb.CreateFont(FontFamily, FooterFontSize);

                font.Bold = true;
                if (HeaderTextColor != "FF000000")
                {
                    font.Color = HeaderTextColor;
                }
                for (uint row = 1; row <= cols.Length; row++)
                {
                    uint rowInd = (uint)(row + headerOffset);
                    sheet.Rows[rowInd].Height = RowHeight;

                    for (uint col = 1; col <= cols[row - 1].Length; col++)
                    {
                        if (BGColor != "FFFFFFFF")
                        {
                            sheet.Cells[rowInd, col].Style.Fill.ForegroundColor = BGColor;
                        }
                        sheet.Cells[rowInd, col].Style.Font = font;
                        //TODO add text color, vertical alignment, horizontal alignment
                        sheet.Cells[rowInd, col].Style.Border = border;
                        sheet.Cells[rowInd, col].Value        = cols[row - 1][col - 1].GetName();
                    }
                }
            }
            headerOffset += cols.Length;
        }
Beispiel #2
0
        private void headerPrint(ExcelXmlParser parser)
        {
            cols = parser.getColumnsInfo("head");
            //Widths
            int[] widths = parser.getWidths();
            if (this.Widths != null)
            {
                foreach (var index in this.Widths.Keys)
                {
                    if (index >= 0 && index < widths.Length)
                    {
                        widths[index] = Widths[index];
                    }
                }
            }
            this.cols_stat = widths.Length;



            int sumWidth = 0;

            for (int i = 0; i < widths.Length; i++)
            {
                sumWidth += widths[i];
            }

            if (parser.getWithoutHeader() == false)
            {
                ExcelFont font = wb.CreateFont(FontFamily, HeaderFontSize);
                font.Bold = true;
                if (HeaderTextColor != "FF000000")
                {
                    font.Color = HeaderTextColor;
                }

                ExcelBorder border = getBorder();


                for (uint row = 1; row <= cols.Length; row++)
                {
                    sheet.Rows[row].Height = RowHeight;
                    for (uint col = 1; col <= cols[row - 1].Length; col++)
                    {
                        sheet.Cells[row, col].Style.Font = font;//if bold font assigned after border - all table will be bold, weird, find out later

                        sheet.Cells[row, col].Style.Border = border;

                        sheet.Columns[col].Width = widths[col - 1] / scale;
                        String name = cols[row - 1][col - 1].GetName();
                        if (BGColor != "FFFFFFFF")
                        {
                            sheet.Cells[row, col].Style.Fill.ForegroundColor = BGColor;
                        }



                        ///TODO:
                        ///font color, merge cells, alignment
                        sheet.Cells[row, col].Value = name;
                        colsNumber = (int)col;
                    }
                }
                headerOffset = cols.Length;
            }
        }