Exemple #1
0
        static void WriteLine(
            IXLWorksheet sheet,
            string[] cols,
            List <IXLCell> cells,
            ref int nItemIndex,
            ref int nRowIndex,
            ref List <int> column_max_chars)
        {
            int nColIndex = 2;

            foreach (string s in cols)
            {
                // 统计最大字符数
                ClosedXmlUtil.SetMaxChars(/*ref*/ column_max_chars, nColIndex - 1, ReaderSearchForm.GetCharWidth(s));

                IXLCell cell = null;
                cell = sheet.Cell(nRowIndex, nColIndex).SetValue(s);
                if (nColIndex == 2)
                {
                    // cell = sheet.Cell(nRowIndex, nColIndex).SetValue(nItemIndex + 1);
                    cell.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                }

                cell.Style.Alignment.WrapText = true;
                cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
                nColIndex++;
                cells?.Add(cell);
            }

            nItemIndex++;
            nRowIndex++;
        }
Exemple #2
0
            public void SetCellText(long value)
            {
                List <int> column_max_chars = this.ColumnMaxChars;

                ClosedXmlUtil.SetMaxChars(/*ref*/ column_max_chars,
                                          TABLE_LEFT_BLANK_COLUMS + this.Column,
                                          value.ToString().Length);
                this.ColumnMaxChars = column_max_chars;
                WriteExcelCell(
                    this.Sheet,
                    TABLE_TOP_BLANK_LINES + this.Line,
                    TABLE_LEFT_BLANK_COLUMS + this.Column,
                    value);
                this.Column++;
            }
Exemple #3
0
 static void SetCellText(
     IXLWorksheet sheet,
     int line,
     ref int column,
     string text,
     ref List <int> column_max_chars)
 {
     ClosedXmlUtil.SetMaxChars(/*ref*/ column_max_chars,
                               column,
                               text.Length);
     WriteExcelCell(
         sheet,
         line,
         column++,
         text);
 }
Exemple #4
0
            public IXLCell SetCellText(string text)
            {
                List <int> column_max_chars = this.ColumnMaxChars;

                ClosedXmlUtil.SetMaxChars(/*ref*/ column_max_chars,
                                          TABLE_LEFT_BLANK_COLUMS + this.Column,
                                          text.Length);
                this.ColumnMaxChars = column_max_chars;
                IXLCell cell = WriteExcelCell(
                    this.Sheet,
                    TABLE_TOP_BLANK_LINES + this.Line,
                    TABLE_LEFT_BLANK_COLUMS + this.Column,
                    text);

                this.Column++;
                return(cell);
            }