Exemplo n.º 1
0
        private void WriteCellXml(ExcelValueObject val, int cellIndex, string extraAttributes)
        {
            string[] DefaultStyles =
                {
                    "",
                    "s21",
                    "s22",
                    "s23",
                    "s24",
                    "s25"
                };

            string[] DefaultFormats =
                {
                    "String",
                    "Number",
                    "DateTime"
                };

            StringBuilder sb = new StringBuilder();

            sb.Append("<Cell");

            sb.Append(extraAttributes);

            if (cellIndex > 0)
            {
                sb.Append(" ss:Index=\"" + cellIndex.ToString() + "\"");
            }

            if (val.MergeAcrossCount > 0)
            {
                sb.Append(" ss:MergeAcross=\"" + val.MergeAcrossCount.ToString() + "\"");
            }

            if (val.MergeDownCount > 0)
            {
                sb.Append(" ss:MergeDown=\"" + val.MergeDownCount.ToString() + "\"");
            }

            string style;
            if (val.Style == ExcelCellStyle.Custom)
            {
                style = val.CustomStyle;
            }
            else
            {
                style = DefaultStyles[(int)val.Style];
            }

            if (!String.IsNullOrEmpty(style))
            {
                sb.Append(" ss:StyleID=\"" + style + "\"");
            }

            sb.Append("><Data ss:Type=\"");
            sb.Append(DefaultFormats[(int)val.Format]);
            sb.Append("\">");

            sb.Append(EscapeXmlString(val.Text));
            sb.Append("</Data>");

            if (_title)
            {
                sb.Append("<NamedCell ss:Name=\"Print_Titles\"/>");
            }

            sb.Append("</Cell>");
            _streamWriter.WriteLine(sb.ToString());
        }
Exemplo n.º 2
0
        public void WriteRow(int rowNumber, ExcelValueObject[] values)
        {
            OpenRow(rowNumber);

            foreach (ExcelValueObject val in values)
            {
                WriteCell(val);
            }

            CloseRow();
        }
Exemplo n.º 3
0
 public void WriteCell(ExcelValueObject val, int cellIndex)
 {
     WriteCellXml(val, cellIndex, String.Empty);
 }
Exemplo n.º 4
0
 public void WriteCellWithFormula(ExcelValueObject val, string Formula)
 {
     WriteCellXml(val, -1, " ss:Formula=\"" + Formula + "\"");
 }
Exemplo n.º 5
0
 public void WriteCell(ExcelValueObject val)
 {
     WriteCell(val, -1);
 }