/** * Write this table out as XML. * * @param out The stream to write to. * @throws IOException if an error occurs while writing. */ public void WriteTo(Stream out1) { // Work on the current one // Need to do this, as we don't handle // all the possible entries yet CT_Stylesheet styleSheet = doc.GetStyleSheet(); // Formats CT_NumFmts ctFormats = new CT_NumFmts(); ctFormats.count = (uint)numberFormats.Count; if (ctFormats.count > 0) { ctFormats.countSpecified = true; } foreach (KeyValuePair <int, String> fmt in numberFormats) { CT_NumFmt ctFmt = ctFormats.AddNewNumFmt(); ctFmt.numFmtId = (uint)fmt.Key; ctFmt.formatCode = fmt.Value; } if (ctFormats.count > 0) { styleSheet.numFmts = ctFormats; } // Fonts CT_Fonts ctFonts = new CT_Fonts(); ctFonts.count = (uint)fonts.Count; if (ctFonts.count > 0) { ctFonts.countSpecified = true; } List <CT_Font> ctfnt = new List <CT_Font>(fonts.Count); foreach (XSSFFont f in fonts) { ctfnt.Add(f.GetCTFont()); } ctFonts.SetFontArray(ctfnt); styleSheet.fonts = (ctFonts); // Fills List <CT_Fill> ctf = new List <CT_Fill>(fills.Count); foreach (XSSFCellFill f in fills) { ctf.Add(f.GetCTFill()); } CT_Fills ctFills = new CT_Fills(); ctFills.SetFillArray(ctf); ctFills.count = (uint)fills.Count; if (ctFills.count > 0) { ctFills.countSpecified = true; } styleSheet.fills = ctFills; // Borders List <CT_Border> ctb = new List <CT_Border>(borders.Count); foreach (XSSFCellBorder b in borders) { ctb.Add(b.GetCTBorder()); } CT_Borders ctBorders = new CT_Borders(); ctBorders.SetBorderArray(ctb); ctBorders.count = (uint)ctb.Count; styleSheet.borders = ctBorders; // Xfs if (xfs.Count > 0) { CT_CellXfs ctXfs = new CT_CellXfs(); ctXfs.count = (uint)xfs.Count; if (ctXfs.count > 0) { ctXfs.countSpecified = true; } ctXfs.xf = xfs; styleSheet.cellXfs = (ctXfs); } // Style xfs if (styleXfs.Count > 0) { CT_CellStyleXfs ctSXfs = new CT_CellStyleXfs(); ctSXfs.count = (uint)(styleXfs.Count); if (ctSXfs.count > 0) { ctSXfs.countSpecified = true; } ctSXfs.xf = styleXfs; styleSheet.cellStyleXfs = (ctSXfs); } // Style dxfs if (dxfs.Count > 0) { CT_Dxfs ctDxfs = new CT_Dxfs(); ctDxfs.count = (uint)dxfs.Count; if (ctDxfs.count > 0) { ctDxfs.countSpecified = true; } ctDxfs.dxf = dxfs; styleSheet.dxfs = (ctDxfs); } // Save doc.Save(out1); }
public void WriteTo(Stream out1) { CT_Stylesheet styleSheet = this.doc.GetStyleSheet(); CT_NumFmts ctNumFmts = new CT_NumFmts(); ctNumFmts.count = (uint)this.numberFormats.Count; if (ctNumFmts.count > 0U) { ctNumFmts.countSpecified = true; } foreach (KeyValuePair <int, string> numberFormat in this.numberFormats) { CT_NumFmt ctNumFmt = ctNumFmts.AddNewNumFmt(); ctNumFmt.numFmtId = (uint)numberFormat.Key; ctNumFmt.formatCode = numberFormat.Value; } styleSheet.numFmts = ctNumFmts; CT_Fonts ctFonts = new CT_Fonts(); ctFonts.count = (uint)this.fonts.Count; if (ctFonts.count > 0U) { ctFonts.countSpecified = true; } CT_Font[] array1 = new CT_Font[this.fonts.Count]; int num = 0; foreach (XSSFFont font in this.fonts) { array1[num++] = font.GetCTFont(); } ctFonts.SetFontArray(array1); styleSheet.fonts = ctFonts; List <CT_Fill> array2 = new List <CT_Fill>(this.fills.Count); foreach (XSSFCellFill fill in this.fills) { array2.Add(fill.GetCTFill()); } CT_Fills ctFills = new CT_Fills(); ctFills.SetFillArray(array2); ctFills.count = (uint)this.fills.Count; if (ctFills.count > 0U) { ctFills.countSpecified = true; } styleSheet.fills = ctFills; List <CT_Border> array3 = new List <CT_Border>(this.borders.Count); foreach (XSSFCellBorder border in this.borders) { array3.Add(border.GetCTBorder()); } CT_Borders ctBorders = new CT_Borders(); ctBorders.SetBorderArray(array3); ctBorders.count = (uint)array3.Count; if (ctBorders.count > 0U) { ctBorders.countSpecified = true; } styleSheet.borders = ctBorders; if (this.xfs.Count > 0) { CT_CellXfs ctCellXfs = new CT_CellXfs(); ctCellXfs.count = (uint)this.xfs.Count; if (ctCellXfs.count > 0U) { ctCellXfs.countSpecified = true; } ctCellXfs.xf = this.xfs; styleSheet.cellXfs = ctCellXfs; } if (this.styleXfs.Count > 0) { CT_CellStyleXfs ctCellStyleXfs = new CT_CellStyleXfs(); ctCellStyleXfs.count = (uint)this.styleXfs.Count; if (ctCellStyleXfs.count > 0U) { ctCellStyleXfs.countSpecified = true; } ctCellStyleXfs.xf = this.styleXfs; styleSheet.cellStyleXfs = ctCellStyleXfs; } if (this.dxfs.Count > 0) { CT_Dxfs ctDxfs = new CT_Dxfs(); ctDxfs.count = (uint)this.dxfs.Count; if (ctDxfs.count > 0U) { ctDxfs.countSpecified = true; } ctDxfs.dxf = this.dxfs; styleSheet.dxfs = ctDxfs; } this.doc.Save(out1); }