private void LayerShape(FastString Page, ShapeObject obj, FastString text) { int styleindex = UpdateCSSTable(obj); string style = GetStyleTag(styleindex); string old_text = String.Empty; float Width, Height; string pic = GetLayerPicture(obj, out Width, out Height); FastString addstyle = new FastString(64); if (obj.Shape == ShapeKind.Rectangle || obj.Shape == ShapeKind.RoundRectangle) { if (obj.FillColor.A != 0) { addstyle.Append("background:").Append(System.Drawing.ColorTranslator.ToHtml(obj.FillColor)).Append(";"); } addstyle.Append("border-style:solid;"); if (obj.Border.Width != 3) { addstyle.Append("border-width:").Append(ExportUtils.FloatToString(obj.Border.Width)).Append("px;"); } addstyle.Append("border-color:").Append(System.Drawing.ColorTranslator.ToHtml(obj.Border.Color)).Append(";"); if (obj.Shape == ShapeKind.RoundRectangle) { addstyle.Append("border-radius:15px;"); } } float x = obj.Width > 0 ? obj.AbsLeft : (obj.AbsLeft + obj.Width); float y = obj.Height > 0 ? hPos + obj.AbsTop : (hPos + obj.AbsTop + obj.Height); Layer(Page, obj, x, y, obj.Width, obj.Height, text, style, addstyle); addstyle.Clear(); }
private void OdfRowStyles(StreamWriter Out) { List <string> FList = new List <string>(); string s; for (int i = 0; i < FMatrix.Height - 1; i++) { s = ExportUtils.FloatToString((FMatrix.YPosById(i + 1) - FMatrix.YPosById(i)) / odfDivider); if (FList.IndexOf(s) == -1) { FList.Add(s); } } FList.Sort(); for (int i = 0; i < FList.Count; i++) { Out.WriteLine("<style:style style:name=\"ro" + FList[i] + "\" " + "style:family=\"table-row\">"); Out.WriteLine("<style:table-row-properties fo:break-before=\"auto\" " + "style:row-height=\"" + FList[i] + "cm\"/>"); Out.WriteLine("</style:style>"); } Out.WriteLine("<style:style style:name=\"ro_breaked\" " + "style:family=\"table-row\">"); Out.WriteLine("<style:table-row-properties fo:break-before=\"page\" " + "style:row-height=\"0.001cm\"/>"); Out.WriteLine("</style:style>"); Out.WriteLine("<style:style style:name=\"ta1\" style:family=\"table\" style:master-page-name=\"PageDef\">"); Out.WriteLine("<style:table-properties table:display=\"true\" style:writing-mode=\"lr-tb\"/>"); Out.WriteLine("</style:style>"); Out.WriteLine("<style:style style:name=\"ceb\" style:family=\"table-cell\" style:display=\"false\"/>"); }
private void OdfMakeDocStyles(string FileName) { using (FileStream file = new FileStream(FileName, FileMode.Create)) using (StreamWriter Out = new StreamWriter(file)) { Out.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); Out.Write("<office:document-styles "); Out.Write(OdfMakeXmlHeader()); Out.WriteLine(">"); Out.WriteLine("<office:automatic-styles>"); // rework! Out.WriteLine("<style:page-layout style:name=\"pm1\">"); Out.WriteLine("<style:page-layout-properties " + "fo:page-width=\"" + ExportUtils.FloatToString(FPageWidth / odfPageDiv) + "cm\" " + "fo:page-height=\"" + ExportUtils.FloatToString(FPageHeight / odfPageDiv) + "cm\" " + "fo:margin-top=\"" + ExportUtils.FloatToString(FPageTop / odfMargDiv) + "cm\" " + "fo:margin-bottom=\"" + ExportUtils.FloatToString(FPageBottom / odfMargDiv) + "cm\" " + "fo:margin-left=\"" + ExportUtils.FloatToString(FPageLeft / odfMargDiv) + "cm\" " + "fo:margin-right=\"" + ExportUtils.FloatToString(FPageRight / odfMargDiv) + "cm\"/>"); Out.WriteLine("</style:page-layout>"); Out.WriteLine("</office:automatic-styles>"); Out.WriteLine("<office:master-styles>"); Out.WriteLine("<style:master-page style:name=\"PageDef\" style:page-layout-name=\"pm1\">"); Out.WriteLine("<style:header style:display=\"false\"/>"); Out.WriteLine("<style:footer style:display=\"false\"/>"); Out.WriteLine("</style:master-page>"); Out.WriteLine("</office:master-styles>"); Out.WriteLine("</office:document-styles>"); } }
private void OdfTableCellStyles(ExportIEMStyle Style, StreamWriter Out) { Out.Write("<style:table-cell-properties fo:background-color=\"" + ExportUtils.HTMLColor(Style.FillColor) + "\" " + "style:repeat-content=\"false\" fo:wrap-option=\"wrap\" "); if (Style.Angle > 0) { Out.Write("style:rotation-angle=\"" + (360 - Style.Angle).ToString() + "\" " + "style:rotation-align=\"none\" "); } if (Style.VAlign == VertAlign.Center) { Out.Write("style:vertical-align=\"middle\" "); } if (Style.VAlign == VertAlign.Top) { Out.Write("style:vertical-align=\"top\" "); } if (Style.VAlign == VertAlign.Bottom) { Out.Write("style:vertical-align=\"bottom\" "); } if ((Style.Border.Lines & BorderLines.Left) > 0) { Out.Write("fo:border-left=\"" + ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " + OdfGetFrameName(Style.Border.Style) + " " + ExportUtils.HTMLColor(Style.Border.Color) + "\" "); } if ((Style.Border.Lines & BorderLines.Right) > 0) { Out.Write("fo:border-right=\"" + ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " + OdfGetFrameName(Style.Border.Style) + " " + ExportUtils.HTMLColor(Style.Border.Color) + "\" "); } if ((Style.Border.Lines & BorderLines.Top) > 0) { Out.Write("fo:border-top=\"" + ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " + OdfGetFrameName(Style.Border.Style) + " " + ExportUtils.HTMLColor(Style.Border.Color) + "\" "); } if ((Style.Border.Lines & BorderLines.Bottom) > 0) { Out.Write("fo:border-bottom=\"" + ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " + OdfGetFrameName(Style.Border.Style) + " " + ExportUtils.HTMLColor(Style.Border.Color) + "\" "); } Out.WriteLine("/>"); Out.WriteLine("</style:style>"); }
private string GetXMLFont(ExportIEMStyle style) { StringBuilder result = new StringBuilder(128); result.Append("<Font ss:FontName=\"").Append(style.Font.Name).Append("\" ss:Size=\""). Append(ExportUtils.FloatToString(style.Font.Size)).Append("\" ss:Color=\""). Append(ExportUtils.HTMLColor(style.TextColor)).Append("\" "). Append(((style.Font.Style & FontStyle.Bold) > 0 ? "ss:Bold=\"1\" " : String.Empty)). Append(((style.Font.Style & FontStyle.Italic) > 0 ? "ss:Italic=\"1\" " : String.Empty)). Append(((style.Font.Style & FontStyle.Underline) > 0 ? "ss:Underline=\"Single\" " : String.Empty)). Append("/>"); return(result.ToString()); }
private void OdfColumnStyles(StreamWriter Out) { List <string> FList = new List <string>(); string s; for (int i = 1; i < FMatrix.Width; i++) { s = ExportUtils.FloatToString((FMatrix.XPosById(i) - FMatrix.XPosById(i - 1)) / odfDivider); if (FList.IndexOf(s) == -1) { FList.Add(s); } } FList.Sort(); for (int i = 0; i < FList.Count; i++) { Out.WriteLine("<style:style style:name=\"co" + FList[i] + "\" " + "style:family=\"table-column\">"); Out.WriteLine("<style:table-column-properties fo:break-before=\"auto\" " + "style:column-width=\"" + FList[i] + "cm\"/>"); Out.WriteLine("</style:style>"); } }
private void ExportODF(Stream stream) { string s; int fx, fy, dx, dy, Page; string FTempFolder = Path.GetTempPath() + Path.GetRandomFileName(); Directory.CreateDirectory(FTempFolder); Directory.CreateDirectory(FTempFolder + "\\Pictures"); Directory.CreateDirectory(FTempFolder + "\\Thumbnails"); Directory.CreateDirectory(FTempFolder + "\\META-INF"); int PicCount = 0; Page = 0; OdfMakeDocStyles(FTempFolder + "\\styles.xml"); #region Content.xml using (FileStream file = new FileStream(FTempFolder + "\\content.xml", FileMode.Create)) using (StreamWriter Out = new StreamWriter(file)) { Out.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); Out.Write("<office:document-content "); Out.Write(OdfMakeXmlHeader()); Out.WriteLine(">"); Out.WriteLine("<office:scripts/>"); ExportIEMStyle Style; OdfFontFaceDecals(Out); Out.WriteLine("<office:automatic-styles>"); OdfColumnStyles(Out); OdfRowStyles(Out); for (int i = 0; i < FMatrix.StylesCount; i++) { Style = FMatrix.StyleById(i); Out.WriteLine("<style:style style:name=\"ce" + i.ToString() + "\" " + "style:family=\"table-cell\" style:parent-style-name=\"Default\">"); if (FExportType == 0) { Out.Write("<style:text-properties style:font-name=\"" + Style.Font.Name + "\" " + "fo:font-size=\"" + ExportUtils.FloatToString(Style.Font.Size) + "pt\" "); if ((Style.Font.Style & FontStyle.Underline) > 0) { Out.Write("style:text-underline-style=\"solid\" " + "style:text-underline-width=\"auto\" " + "style:text-underline-color=\"font-color\" "); } if ((Style.Font.Style & FontStyle.Italic) > 0) { Out.Write("fo:font-style=\"italic\" "); } if ((Style.Font.Style & FontStyle.Bold) > 0) { Out.Write("fo:font-weight=\"bold\" "); } Out.Write("fo:color=\"" + ExportUtils.HTMLColor(Style.TextColor) + "\""); Out.WriteLine("/>"); Out.Write("<style:paragraph-properties "); if (Style.HAlign == HorzAlign.Left) { Out.Write("fo:text-align=\"start\" "); } if (Style.HAlign == HorzAlign.Center) { Out.Write("fo:text-align=\"center\" "); } if (Style.HAlign == HorzAlign.Right) { Out.Write("fo:text-align=\"end\" "); } if (Style.Padding.Left > 0) { Out.Write("fo:margin-left=\"" + ExportUtils.FloatToString(Style.Padding.Left / odfDivider) + "cm\" "); } if (Style.Padding.Right > 0) { Out.Write("fo:margin-right=\"" + ExportUtils.FloatToString(Style.Padding.Right / odfDivider) + "cm\" "); } if (Style.Padding.Top > 0) { Out.Write("fo:margin-top=\"" + ExportUtils.FloatToString(Style.Padding.Top / odfDivider) + "cm\" "); } if (Style.Padding.Bottom > 0) { Out.Write("fo:margin-bottom=\"" + ExportUtils.FloatToString(Style.Padding.Bottom / odfDivider) + "cm\" "); } Out.WriteLine("/>"); } OdfTableCellStyles(Style, Out); } if (FExportType == 1) { Out.WriteLine("<style:style style:name=\"pb\" " + "style:family=\"paragraph\" style:display=\"false\"/>"); for (int i = 0; i < FMatrix.StylesCount; i++) { Style = FMatrix.StyleById(i); Out.WriteLine("<style:style style:name=\"p" + i.ToString() + "\" " + "style:family=\"paragraph\" style:parent-style-name=\"Default\">"); Out.Write("<style:text-properties style:font-name=\"" + Style.Font.Name + "\" fo:font-size=\"" + ExportUtils.FloatToString(Style.Font.Size) + "pt\" "); if ((Style.Font.Style & FontStyle.Underline) > 0) { Out.Write(" style:text-underline-style=\"solid\" " + "style:text-underline-width=\"auto\" " + "style:text-underline-color=\"font-color\" "); } if ((Style.Font.Style & FontStyle.Italic) > 0) { Out.Write(" style:font-style=\"italic\" "); } if ((Style.Font.Style & FontStyle.Bold) > 0) { Out.Write(" style:font-weight=\"bold\" "); } Out.WriteLine(" fo:color=\"" + ExportUtils.HTMLColor(Style.TextColor) + "\"/>"); Out.Write("<style:paragraph-properties "); if (Style.HAlign == HorzAlign.Left) { Out.Write("fo:text-align=\"start\" "); } if (Style.HAlign == HorzAlign.Center) { Out.Write("fo:text-align=\"center\" "); } if (Style.HAlign == HorzAlign.Right) { Out.Write("fo:text-align=\"end\" "); } if (Style.Padding.Left > 0) { Out.Write("fo:margin-left=\"" + ExportUtils.FloatToString(Style.Padding.Left / odfDivider) + "cm\" "); } if (Style.Padding.Right > 0) { Out.Write("fo:margin-right=\"" + ExportUtils.FloatToString(Style.Padding.Right / odfDivider) + "cm\" "); } if (Style.Padding.Top > 0) { Out.Write("fo:margin-top=\"" + ExportUtils.FloatToString(Style.Padding.Top / odfDivider) + "cm\" "); } if (Style.Padding.Bottom > 0) { Out.Write("fo:margin-bottom=\"" + ExportUtils.FloatToString(Style.Padding.Bottom / odfDivider) + "cm\" "); } Out.WriteLine("/>"); Out.WriteLine("</style:style>"); } } Out.WriteLine("<style:style style:name=\"gr1\" style:family=\"graphic\">"); Out.WriteLine("<style:graphic-properties draw:stroke=\"none\" " + "draw:fill=\"none\" draw:textarea-horizontal-align=\"left\" " + "draw:textarea-vertical-align=\"top\" draw:color-mode=\"standard\" " + "draw:luminance=\"0%\" draw:contrast=\"0%\" draw:gamma=\"100%\" " + "draw:red=\"0%\" draw:green=\"0%\" draw:blue=\"0%\" " + "fo:clip=\"rect(0cm 0cm 0cm 0cm)\" draw:image-opacity=\"100%\" " + "style:mirror=\"none\"/>"); Out.WriteLine("</style:style>"); Out.WriteLine("</office:automatic-styles>"); // body Out.WriteLine("<office:body>"); Out.WriteLine("<office:spreadsheet>"); Out.WriteLine("<table:table table:name=\"Table\" table:style-name=\"ta1\" table:print=\"false\">"); for (int x = 1; x < FMatrix.Width; x++) { Out.WriteLine("<table:table-column table:style-name=\"co" + ExportUtils.FloatToString((FMatrix.XPosById(x) - FMatrix.XPosById(x - 1)) / odfDivider) + "\"/>"); } for (int y = 0; y < FMatrix.Height - 1; y++) { Out.WriteLine("<table:table-row table:style-name=\"ro" + ExportUtils.FloatToString((FMatrix.YPosById(y + 1) - FMatrix.YPosById(y)) / odfDivider) + "\">"); if (FMatrix.YPosById(y) >= FMatrix.PageBreak(Page)) { Page++; if (FPageBreaks) { Out.WriteLine("<table:table-row table:style-name=\"ro_breaked\"/>"); } } for (int x = 0; x < FMatrix.Width; x++) { int i = FMatrix.Cell(x, y); if (i != -1) { ExportIEMObject Obj = FMatrix.ObjectById(i); if (Obj.Counter == 0) { Obj.Counter = 1; FMatrix.ObjectPos(i, out fx, out fy, out dx, out dy); Out.Write("<table:table-cell table:style-name=\"ce" + Obj.StyleIndex.ToString() + "\" "); if (dx > 1) { Out.Write("table:number-columns-spanned=\"" + dx.ToString() + "\" "); } if (dy > 1) { Out.Write("table:number-rows-spanned=\"" + dy.ToString() + "\" "); } Out.WriteLine(">"); if (Obj.IsText) { s = ExportUtils.XmlString(Obj.Text, Obj.HtmlTags); Out.Write("<text:p"); if (FExportType == 1) { Out.Write(" text:style-name=\"p" + Obj.StyleIndex.ToString() + "\""); } Out.WriteLine(">" + s + "</text:p>"); } else { if (Obj.Width > 0) { PicCount++; if (Config.FullTrust) { using (FileStream emfFile = new FileStream(FTempFolder + "\\Pictures\\pic" + PicCount.ToString() + ".emf", FileMode.Create)) emfFile.Write(Obj.PictureStream.ToArray(), 0, (int)Obj.PictureStream.Length); } else { using (FileStream pngFile = new FileStream(FTempFolder + "\\Pictures\\pic" + PicCount.ToString() + ".png", FileMode.Create)) pngFile.Write(Obj.PictureStream.ToArray(), 0, (int)Obj.PictureStream.Length); } if (FExportType == 1) { Out.WriteLine("<text:p>"); } // need for fix of vertical position Out.WriteLine("<draw:frame draw:z-index=\"" + (PicCount - 1).ToString() + "\" " + "draw:name=\"Pictures" + PicCount.ToString() + "\" " + "draw:style-name=\"gr1\" " + "draw:text-style-name=\"P1\" " + "svg:width=\"" + ExportUtils.FloatToString(Obj.Width / odfDivider) + "cm\" " + "svg:height=\"" + ExportUtils.FloatToString(Obj.Height / odfDivider) + "cm\" " + "svg:x=\"0cm\" svg:y=\"0cm\">"); s = Config.FullTrust ? ".emf" : ".png"; Out.WriteLine("<draw:image " + "xlink:href=\"Pictures/pic" + PicCount.ToString() + s + "\" " + "text:anchor-type=\"frame\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>"); Out.WriteLine("</draw:frame>"); if (FExportType == 1) { Out.WriteLine("</text:p>"); } } } Out.WriteLine("</table:table-cell>"); } else { Out.Write("<table:covered-table-cell table:style-name=\"ceb\""); if (FExportType == 1) { Out.WriteLine("><text:p text:style-name=\"pb\"/></table:covered-table-cell>"); } else { Out.WriteLine("/>"); } } } else { Out.Write("<table:table-cell"); if (FExportType == 1) { Out.WriteLine("><text:p text:style-name=\"pb\"/></table:table-cell>"); } else { Out.WriteLine("/>"); } } } Out.WriteLine("</table:table-row>"); } Out.WriteLine("</table:table>"); Out.WriteLine("</office:spreadsheet>"); Out.WriteLine("</office:body>"); Out.WriteLine("</office:document-content>"); } #endregion string ExportMime = FExportType == 0 ? "spreadsheet" : "text"; OdfCreateManifest(FTempFolder + "\\META-INF\\manifest.xml", PicCount, ExportMime); OdfCreateMime(FTempFolder + "\\mimetype", ExportMime); OdfCreateMeta(FTempFolder + "\\meta.xml", Creator); ZipArchive zip = new ZipArchive(); zip.AddDir(FTempFolder); zip.SaveToStream(Stream); Directory.Delete(FTempFolder, true); }
private void ExportXML(Stream stream) { int i, x, y, fx, fy, dx, dy; ExportIEMObject Obj; ExportIEMStyle EStyle; StringBuilder builder = new StringBuilder(8448); builder.AppendLine("<?xml version=\"1.0\"?>"); builder.AppendLine("<?mso-application progid=\"Excel.Sheet\"?>"); builder.Append("<?fr-application created=\"").Append(FCreator).AppendLine("\"?>"); builder.AppendLine("<?fr-application homesite=\"http://www.fast-report.com\"?>"); builder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\""); builder.Append(" xmlns:o=\"urn:schemas-microsoft-com:office:office\""); builder.Append(" xmlns:x=\"urn:schemas-microsoft-com:office:excel\""); builder.Append(" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\""); builder.AppendLine(" xmlns:html=\"http://www.w3.org/TR/REC-html40\">"); builder.AppendLine("<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">"); builder.Append("<Title>").Append(Report.ReportInfo.Name).AppendLine("</Title>"); builder.Append("<Author>").Append(Report.ReportInfo.Author).AppendLine("</Author>"); builder.Append("<Created>").Append(DateTime.Now.Date.ToString()).Append("T").Append(DateTime.Now.TimeOfDay.ToString()).AppendLine("Z</Created>"); builder.Append("<Version>").Append(Report.ReportInfo.Version).AppendLine("</Version>"); builder.AppendLine("</DocumentProperties>"); builder.AppendLine("<ExcelWorkbook xmlns=\"urn:schemas-microsoft-com:office:excel\">"); builder.AppendLine("<ProtectStructure>False</ProtectStructure>"); builder.AppendLine("<ProtectWindows>False</ProtectWindows>"); builder.AppendLine("</ExcelWorkbook>"); builder.AppendLine("<Styles>"); for (x = 0; x < FMatrix.StylesCount; x++) { EStyle = FMatrix.StyleById(x); builder.Append("<Style ss:ID=\"s").Append(x.ToString()).AppendLine("\">"); builder.AppendLine(GetXMLFont(EStyle)); builder.AppendLine(GetXMLInterior(EStyle)); builder.AppendLine(GetXMLAlignment(EStyle)); builder.AppendLine(GetXMLBorders(EStyle)); builder.Append(GetXMLFormat(EStyle)); builder.AppendLine("</Style>"); } builder.AppendLine("</Styles>"); builder.AppendLine("<Worksheet ss:Name=\"Page 1\">"); // add table builder.Append("<Table ss:ExpandedColumnCount=\"").Append(FMatrix.Width.ToString()).Append("\""). Append(" ss:ExpandedRowCount=\"").Append(FMatrix.Height.ToString()).AppendLine("\" x:FullColumns=\"1\" x:FullRows=\"1\">"); for (x = 1; x < FMatrix.Width; x++) { builder.Append("<Column ss:AutoFitWidth=\"0\" ss:Width=\""). Append(ExportUtils.FloatToString((FMatrix.XPosById(x) - FMatrix.XPosById(x - 1)) / Xdivider)). AppendLine("\"/>"); } WriteBuf(stream, builder); for (y = 0; y < FMatrix.Height - 1; y++) { builder.Append("<Row ss:Height=\""). Append(ExportUtils.FloatToString((FMatrix.YPosById(y + 1) - FMatrix.YPosById(y)) / Ydivider)). AppendLine("\">"); for (x = 0; x < FMatrix.Width; x++) { i = FMatrix.Cell(x, y); if (i != -1) { Obj = FMatrix.ObjectById(i); if (Obj.Counter == 0) { builder.Append("<Cell ss:Index=\""). Append(Convert.ToString(x + 1) + "\" "); FMatrix.ObjectPos(i, out fx, out fy, out dx, out dy); Obj.Counter = 1; if (Obj.IsText) { if (dx > 1) { builder.Append("ss:MergeAcross=\"").Append(Convert.ToString(dx++ - 1)).Append("\" "); } if (dy > 1) { builder.Append("ss:MergeDown=\"").Append(Convert.ToString(dy++ - 1)).Append("\" "); } builder.Append("ss:StyleID=\"s").Append(Obj.StyleIndex.ToString()).AppendLine("\">"); decimal value = 0; bool isNumeric = ExportUtils.ParseTextToDecimal(Obj.Text, Obj.Style.Format, out value); string type = isNumeric ? "ss:Type=\"Number\"" : "ss:Type=\"String\""; string data = Obj.HtmlTags ? "ss:Data" : "Data"; string xmlns = Obj.HtmlTags ? " xmlns=\"http://www.w3.org/TR/REC-html40\"" : String.Empty; string strValue = isNumeric ? Convert.ToString(value, CultureInfo.InvariantCulture.NumberFormat) : ExportUtils.XmlString(Obj.Text, Obj.HtmlTags); builder.Append("<").Append(data).Append(" ").Append(type).Append(xmlns). Append(">").Append(strValue).Append("</").Append(data).Append("></Cell>"); } } } else { builder.Append("<Cell ss:Index=\"").Append(Convert.ToString(x + 1)).Append("\"/>"); } } builder.AppendLine("</Row>"); if (builder.Length > 8192) { WriteBuf(stream, builder); } } builder.AppendLine("</Table>"); builder.AppendLine("<WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">"); if (FMatrix.PagesCount > 0) { builder.AppendLine("<PageSetup>"); if (FMatrix.Landscape(0)) { builder.AppendLine("<Layout x:Orientation=\"Landscape\"/>"); } builder.AppendLine(string.Format(CultureInfo.InvariantCulture, "<PageMargins x:Bottom=\"{0:F2}\"" + " x:Left=\"{1:F2}\"" + " x:Right=\"{2:F2}\"" + " x:Top=\"{3:F2}\"/>", FMatrix.PageBMargin(0) / MargDiv, FMatrix.PageLMargin(0) / MargDiv, FMatrix.PageRMargin(0) / MargDiv, FMatrix.PageTMargin(0) / MargDiv)); builder.AppendLine("</PageSetup>"); builder.AppendLine("<Print>"); builder.AppendLine("<ValidPrinterInfo/>"); builder.AppendLine("<PaperSizeIndex>" + FMatrix.RawPaperSize(0).ToString() + "</PaperSizeIndex>"); builder.AppendLine("</Print>"); } builder.AppendLine("</WorksheetOptions>"); // add page breaks if (FPageBreaks) { builder.AppendLine("<PageBreaks xmlns=\"urn:schemas-microsoft-com:office:excel\">"); builder.AppendLine("<RowBreaks>"); int page = 0; for (i = 0; i <= FMatrix.Height - 1; i++) { if (FMatrix.YPosById(i) >= FMatrix.PageBreak(page)) { builder.AppendLine("<RowBreak>"); builder.AppendLine(string.Format("<Row>{0}</Row>", i)); builder.AppendLine("</RowBreak>"); page++; } } builder.AppendLine("</RowBreaks>"); builder.AppendLine("</PageBreaks>"); } builder.AppendLine("</Worksheet>"); builder.AppendLine("</Workbook>"); WriteBuf(stream, builder); }