XMLExport.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. using System;
  2. using System.Text;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using FastReport.Utils;
  8. using System.Globalization;
  9. using FastReport.Format;
  10. namespace FastReport.Export.Xml
  11. {
  12. /// <summary>
  13. /// Represents the Excel 2003 XML export filter.
  14. /// </summary>
  15. public partial class XMLExport : ExportBase
  16. {
  17. #region Constants
  18. private const int xLMaxHeight = 409;
  19. private const float xdivider = 1.376f;
  20. private const float ydivider = 1.333f;
  21. #endregion
  22. #region Private fields
  23. private bool pageBreaks;
  24. private string creator;
  25. private bool dataOnly;
  26. private bool wysiwyg;
  27. private Dictionary<string, XMLSheet> sheets;
  28. private ExportMatrix matrix;
  29. private XMLSheet sh;
  30. private bool splitPages;
  31. private List<ExportIEMStyle> commonStyles;
  32. #endregion
  33. private class XMLSheet
  34. {
  35. #region Constants
  36. private const float margDiv = 25.4F;
  37. #endregion
  38. #region Private fields
  39. private bool pageBreaks;
  40. private readonly string name;
  41. #endregion
  42. internal readonly ExportMatrix matrix;
  43. public void ExportSheet(Stream stream, StringBuilder builder)
  44. {
  45. int i, x, fx, fy, dx, dy;
  46. ExportIEMObject Obj;
  47. builder.AppendLine("<Worksheet ss:Name=\"" + name + "\">");
  48. // add table
  49. builder.Append("<Table ss:ExpandedColumnCount=\"").Append(matrix.Width.ToString()).Append("\"").
  50. Append(" ss:ExpandedRowCount=\"").Append(matrix.Height.ToString()).AppendLine("\" x:FullColumns=\"1\" x:FullRows=\"1\">");
  51. for (x = 1; x < matrix.Width; x++)
  52. builder.Append("<Column ss:AutoFitWidth=\"0\" ss:Width=\"").
  53. Append(ExportUtils.FloatToString((matrix.XPosById(x) - matrix.XPosById(x - 1)) / xdivider)).
  54. AppendLine("\"/>");
  55. WriteBuf(stream, builder);
  56. for (int y = 0; y < matrix.Height - 1; y++)
  57. {
  58. builder.Append("<Row ss:Height=\"").
  59. Append(ExportUtils.FloatToString((matrix.YPosById(y + 1) - matrix.YPosById(y)) / ydivider)).
  60. AppendLine("\">");
  61. for (x = 0; x < matrix.Width; x++)
  62. {
  63. i = matrix.Cell(x, y);
  64. if (i != -1)
  65. {
  66. Obj = matrix.ObjectById(i);
  67. if (Obj.Counter == 0)
  68. {
  69. builder.Append("<Cell ss:Index=\"").
  70. Append(Convert.ToString(x + 1) + "\" ");
  71. matrix.ObjectPos(i, out fx, out fy, out dx, out dy);
  72. Obj.Counter = 1;
  73. if (Obj.IsText)
  74. {
  75. if (dx > 1)
  76. builder.Append("ss:MergeAcross=\"").Append(Convert.ToString(dx++ - 1)).Append("\" ");
  77. if (dy > 1)
  78. builder.Append("ss:MergeDown=\"").Append(Convert.ToString(dy++ - 1)).Append("\" ");
  79. builder.Append("ss:StyleID=\"s").Append(Obj.StyleIndex.ToString()).AppendLine("\">");
  80. decimal value = 0;
  81. bool isNumeric = ExportUtils.ParseTextToDecimal(Obj.Text, Obj.Style.Format, out value);
  82. string type = isNumeric ? "ss:Type=\"Number\"" : "ss:Type=\"String\"";
  83. string data = Obj.HtmlTags ? "ss:Data" : "Data";
  84. string xmlns = Obj.HtmlTags ? " xmlns=\"http://www.w3.org/TR/REC-html40\"" : String.Empty;
  85. string strValue = isNumeric ?
  86. Convert.ToString(value, CultureInfo.InvariantCulture.NumberFormat) :
  87. ExportUtils.XmlString(Obj.Text, Obj.TextRenderType);
  88. builder.Append("<").Append(data).Append(" ").Append(type).Append(xmlns).
  89. Append(">").Append(strValue).Append("</").Append(data).Append("></Cell>");
  90. }
  91. }
  92. }
  93. else
  94. builder.Append("<Cell ss:Index=\"").Append(Convert.ToString(x + 1)).Append("\"/>");
  95. }
  96. builder.AppendLine("</Row>");
  97. if (builder.Length > 8192)
  98. WriteBuf(stream, builder);
  99. }
  100. builder.AppendLine("</Table>");
  101. builder.AppendLine("<WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">");
  102. if (matrix.PagesCount > 0)
  103. {
  104. builder.AppendLine("<PageSetup>");
  105. if (matrix.Landscape(0))
  106. builder.AppendLine("<Layout x:Orientation=\"Landscape\"/>");
  107. builder.AppendLine(string.Format(CultureInfo.InvariantCulture, "<PageMargins x:Bottom=\"{0:F2}\"" +
  108. " x:Left=\"{1:F2}\"" +
  109. " x:Right=\"{2:F2}\"" +
  110. " x:Top=\"{3:F2}\"/>",
  111. matrix.PageBMargin(0) / margDiv,
  112. matrix.PageLMargin(0) / margDiv,
  113. matrix.PageRMargin(0) / margDiv,
  114. matrix.PageTMargin(0) / margDiv));
  115. builder.AppendLine("</PageSetup>");
  116. builder.AppendLine("<Print>");
  117. builder.AppendLine("<ValidPrinterInfo/>");
  118. builder.AppendLine("<PaperSizeIndex>" + matrix.RawPaperSize(0).ToString() + "</PaperSizeIndex>");
  119. builder.AppendLine("</Print>");
  120. }
  121. builder.AppendLine("</WorksheetOptions>");
  122. // add page breaks
  123. if (pageBreaks)
  124. {
  125. builder.AppendLine("<PageBreaks xmlns=\"urn:schemas-microsoft-com:office:excel\">");
  126. builder.AppendLine("<RowBreaks>");
  127. int page = 0;
  128. for (i = 0; i <= matrix.Height - 1; i++)
  129. {
  130. if (matrix.YPosById(i) >= matrix.PageBreak(page))
  131. {
  132. builder.AppendLine("<RowBreak>");
  133. builder.AppendLine(string.Format("<Row>{0}</Row>", i));
  134. builder.AppendLine("</RowBreak>");
  135. page++;
  136. }
  137. }
  138. builder.AppendLine("</RowBreaks>");
  139. builder.AppendLine("</PageBreaks>");
  140. }
  141. builder.AppendLine("</Worksheet>");
  142. WriteBuf(stream, builder);
  143. }
  144. public XMLSheet(ExportMatrix matrix, string name, bool pageBreaks)
  145. {
  146. this.matrix = matrix;
  147. this.name = name;
  148. this.pageBreaks = pageBreaks;
  149. }
  150. }
  151. #region Properties
  152. /// <summary>
  153. /// Gets or sets a value that determines whether to insert page breaks in the output file or not.
  154. /// </summary>
  155. ///
  156. public bool PageBreaks
  157. {
  158. get { return pageBreaks; }
  159. set { pageBreaks = value; }
  160. }
  161. /// <summary>
  162. /// Gets or sets a value that determines whether the wysiwyg mode should be used
  163. /// for better results.
  164. /// </summary>
  165. /// <remarks>
  166. /// Default value is <b>true</b>. In wysiwyg mode, the resulting Excel file will look
  167. /// as close as possible to the prepared report. On the other side, it may have a lot
  168. /// of small rows/columns, which will make it less editable. If you set this property
  169. /// to <b>false</b>, the number of rows/columns in the resulting file will be decreased.
  170. /// You will get less wysiwyg, but more editable file.
  171. /// </remarks>
  172. public bool Wysiwyg
  173. {
  174. get { return wysiwyg; }
  175. set { wysiwyg = value; }
  176. }
  177. /// <summary>
  178. /// Gets or sets the name of document creator.
  179. /// </summary>
  180. public string Creator
  181. {
  182. get { return creator; }
  183. set { creator = value; }
  184. }
  185. /// <summary>
  186. /// Gets or sets a value that determines whether to export the databand rows only.
  187. /// </summary>
  188. public bool DataOnly
  189. {
  190. get { return dataOnly; }
  191. set { dataOnly = value; }
  192. }
  193. /// <summary>
  194. /// Each report page is placed on a new Excel page.
  195. /// </summary>
  196. public bool SplitPages
  197. {
  198. get { return splitPages; }
  199. set { splitPages = value; }
  200. }
  201. #endregion
  202. #region Private Methods
  203. private static void WriteBuf(Stream stream, StringBuilder buf)
  204. {
  205. // write the resulting string to a stream
  206. byte[] bytes = Encoding.UTF8.GetBytes(buf.ToString());
  207. stream.Write(bytes, 0, bytes.Length);
  208. buf.Length = 0;
  209. }
  210. private void ExportHeader(StringBuilder builder)
  211. {
  212. builder.AppendLine("<?xml version=\"1.0\"?>");
  213. builder.AppendLine("<?mso-application progid=\"Excel.Sheet\"?>");
  214. builder.Append("<?fr-application created=\"").Append(creator).AppendLine("\"?>");
  215. builder.AppendLine("<?fr-application homesite=\"http://www.fast-report.com\"?>");
  216. builder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"");
  217. builder.Append(" xmlns:o=\"urn:schemas-microsoft-com:office:office\"");
  218. builder.Append(" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"");
  219. builder.Append(" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"");
  220. builder.AppendLine(" xmlns:html=\"http://www.w3.org/TR/REC-html40\">");
  221. builder.AppendLine("<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">");
  222. builder.Append("<Title>").Append(Report.ReportInfo.Name).AppendLine("</Title>");
  223. builder.Append("<Author>").Append(Report.ReportInfo.Author).AppendLine("</Author>");
  224. builder.Append("<Created>").Append(SystemFake.DateTime.Now.Date.ToString()).Append("T").Append(SystemFake.DateTime.Now.TimeOfDay.ToString()).AppendLine("Z</Created>");
  225. builder.Append("<Version>").Append(Report.ReportInfo.Version).AppendLine("</Version>");
  226. builder.AppendLine("</DocumentProperties>");
  227. builder.AppendLine("<ExcelWorkbook xmlns=\"urn:schemas-microsoft-com:office:excel\">");
  228. builder.AppendLine("<ProtectStructure>False</ProtectStructure>");
  229. builder.AppendLine("<ProtectWindows>False</ProtectWindows>");
  230. builder.AppendLine("</ExcelWorkbook>");
  231. }
  232. private void ExportSheets(Stream stream, StringBuilder builder)
  233. {
  234. foreach (XMLSheet sheet in sheets.Values)
  235. sheet.ExportSheet(stream, builder);
  236. builder.AppendLine("</Workbook>");
  237. WriteBuf(stream, builder);
  238. }
  239. private void ExportXML(Stream stream)
  240. {
  241. StringBuilder builder = new StringBuilder(8448);
  242. ExportHeader(builder);
  243. ExportStyles(builder);
  244. ExportSheets(stream, builder);
  245. }
  246. #endregion
  247. #region StyleMethods
  248. internal void ExportStyles(StringBuilder builder)
  249. {
  250. builder.AppendLine("<Styles>");
  251. ExportIEMStyle EStyle;
  252. for (int x = 0; x < commonStyles.Count; x++)
  253. {
  254. EStyle = commonStyles[x];
  255. builder.Append("<Style ss:ID=\"s").Append(x.ToString()).AppendLine("\">");
  256. builder.AppendLine(GetXMLFont(EStyle));
  257. builder.AppendLine(GetXMLInterior(EStyle));
  258. builder.AppendLine(GetXMLAlignment(EStyle));
  259. builder.AppendLine(GetXMLBorders(EStyle));
  260. builder.Append(GetXMLFormat(EStyle));
  261. builder.AppendLine("</Style>");
  262. }
  263. builder.AppendLine("</Styles>");
  264. }
  265. private string GetXMLWeight(float lineWeight)
  266. {
  267. float LineWeight = lineWeight * xdivider;
  268. return ((int)Math.Round(LineWeight > 3 ? 3 : LineWeight)).ToString();
  269. }
  270. private string XmlAlign(HorzAlign horzAlign, VertAlign vertAlign, int angle)
  271. {
  272. string Fh = "Left", Fv = "Top";
  273. if (angle == 0 || angle == 180)
  274. {
  275. if (horzAlign == HorzAlign.Left)
  276. Fh = "Left";
  277. else if (horzAlign == HorzAlign.Right)
  278. Fh = "Right";
  279. else if (horzAlign == HorzAlign.Center)
  280. Fh = "Center";
  281. else if (horzAlign == HorzAlign.Justify)
  282. Fh = "Justify";
  283. if (vertAlign == VertAlign.Top)
  284. Fv = "Top";
  285. else if (vertAlign == VertAlign.Bottom)
  286. Fv = "Bottom";
  287. else if (vertAlign == VertAlign.Center)
  288. Fv = "Center";
  289. }
  290. else if (angle == 90)
  291. {
  292. if (horzAlign == HorzAlign.Left)
  293. Fv = "Top";
  294. else if (horzAlign == HorzAlign.Right)
  295. Fv = "Bottom";
  296. else if (horzAlign == HorzAlign.Center)
  297. Fv = "Center";
  298. if (vertAlign == VertAlign.Top)
  299. Fh = "Right";
  300. else if (vertAlign == VertAlign.Bottom)
  301. Fh = "Left";
  302. else if (vertAlign == VertAlign.Center)
  303. Fh = "Center";
  304. }
  305. else
  306. {
  307. if (horzAlign == HorzAlign.Left)
  308. Fv = "Bottom";
  309. else if (horzAlign == HorzAlign.Right)
  310. Fv = "Top";
  311. else if (horzAlign == HorzAlign.Center)
  312. Fv = "Center";
  313. if (vertAlign == VertAlign.Top)
  314. Fh = "Right";
  315. else if (vertAlign == VertAlign.Bottom)
  316. Fh = "Left";
  317. else if (vertAlign == VertAlign.Center)
  318. Fh = "Center";
  319. }
  320. return "ss:Horizontal=\"" + Fh + "\" ss:Vertical=\"" + Fv + "\"";
  321. }
  322. private string GetXMLBorders(ExportIEMStyle style)
  323. {
  324. StringBuilder result = new StringBuilder(128);
  325. result.AppendLine("<Borders>");
  326. if ((style.Border.Lines & BorderLines.Left) > 0)
  327. result.Append("<Border ss:Position=\"Left\" ").
  328. Append("ss:LineStyle=\"").
  329. AppendFormat(GetXMLLineStyle(style.Border.LeftLine.Style)).
  330. Append("\" ").
  331. Append("ss:Weight=\"").
  332. Append(GetXMLWeight(style.Border.LeftLine.Width)).
  333. Append("\" ").
  334. Append("ss:Color=\"").
  335. Append(ExportUtils.HTMLColorCode(style.Border.LeftLine.Color)).
  336. AppendLine("\"/>");
  337. if ((style.Border.Lines & BorderLines.Top) > 0)
  338. result.Append("<Border ss:Position=\"Top\" ").
  339. Append("ss:LineStyle=\"").
  340. AppendFormat(GetXMLLineStyle(style.Border.TopLine.Style)).
  341. Append("\" ").
  342. Append("ss:Weight=\"").
  343. Append(GetXMLWeight(style.Border.TopLine.Width)).
  344. Append("\" ").
  345. Append("ss:Color=\"").
  346. Append(ExportUtils.HTMLColorCode(style.Border.TopLine.Color)).
  347. AppendLine("\"/>");
  348. if ((style.Border.Lines & BorderLines.Bottom) > 0)
  349. result.AppendLine("<Border ss:Position=\"Bottom\" ").
  350. Append("ss:LineStyle=\"").
  351. AppendFormat(GetXMLLineStyle(style.Border.BottomLine.Style)).
  352. Append("\" ").
  353. Append("ss:Weight=\"").
  354. Append(GetXMLWeight(style.Border.BottomLine.Width)).
  355. Append("\" ").
  356. Append("ss:Color=\"").
  357. Append(ExportUtils.HTMLColorCode(style.Border.BottomLine.Color)).
  358. AppendLine("\"/>");
  359. if ((style.Border.Lines & BorderLines.Right) > 0)
  360. result.AppendLine("<Border ss:Position=\"Right\" ").
  361. Append("ss:LineStyle=\"").
  362. AppendFormat(GetXMLLineStyle(style.Border.RightLine.Style)).
  363. Append("\" ").
  364. Append("ss:Weight=\"").
  365. Append(GetXMLWeight(style.Border.RightLine.Width)).
  366. Append("\" ").
  367. Append("ss:Color=\"").
  368. Append(ExportUtils.HTMLColorCode(style.Border.RightLine.Color)).
  369. AppendLine("\"/>");
  370. result.Append("</Borders>");
  371. return result.ToString();
  372. }
  373. private string GetXMLFont(ExportIEMStyle style)
  374. {
  375. StringBuilder result = new StringBuilder(128);
  376. result.Append("<Font ss:FontName=\"").Append(style.Font.Name).Append("\" ss:Size=\"").
  377. Append(ExportUtils.FloatToString(style.Font.Size)).Append("\" ss:Color=\"").
  378. Append(ExportUtils.HTMLColorCode(style.TextColor)).Append("\" ").
  379. Append(((style.Font.Style & FontStyle.Bold) > 0 ? "ss:Bold=\"1\" " : String.Empty)).
  380. Append(((style.Font.Style & FontStyle.Italic) > 0 ? "ss:Italic=\"1\" " : String.Empty)).
  381. Append(((style.Font.Style & FontStyle.Underline) > 0 ? "ss:Underline=\"Single\" " : String.Empty)).
  382. Append("/>");
  383. return result.ToString();
  384. }
  385. private string GetXMLInterior(ExportIEMStyle style)
  386. {
  387. if (style.FillColor.A != 0)
  388. return "<Interior ss:Color=\"" +
  389. ExportUtils.HTMLColorCode(style.FillColor) + "\" ss:Pattern=\"Solid\"/>";
  390. return String.Empty;
  391. }
  392. private string GetXMLAlignment(ExportIEMStyle style)
  393. {
  394. StringBuilder result = new StringBuilder(64);
  395. result.Append("<Alignment ").Append(XmlAlign(style.HAlign, style.VAlign, style.Angle)).
  396. Append(" ss:WrapText=\"1\" ").
  397. Append(((style.Angle > 0 && style.Angle <= 90) ? "ss:Rotate=\"" + (-style.Angle).ToString() + "\"" : String.Empty)).
  398. Append(((style.Angle > 90 && style.Angle <= 180) ? "ss:Rotate=\"" + (180 - style.Angle).ToString() + "\"" : String.Empty)).
  399. Append(((style.Angle > 180 && style.Angle < 270) ? "ss:Rotate=\"" + (270 - style.Angle).ToString() + "\"" : String.Empty)).
  400. Append(((style.Angle >= 270 && style.Angle < 360) ? "ss:Rotate=\"" + (360 - style.Angle).ToString() + "\"" : String.Empty)).
  401. Append("/>");
  402. return result.ToString();
  403. }
  404. private string GetXMLLineStyle(LineStyle style)
  405. {
  406. switch (style)
  407. {
  408. case LineStyle.Dash:
  409. return "Dash";
  410. case LineStyle.DashDot:
  411. return "DashDot";
  412. case LineStyle.DashDotDot:
  413. return "DashDotDot";
  414. case LineStyle.Dot:
  415. return "Dot";
  416. case LineStyle.Double:
  417. return "Double";
  418. default:
  419. return "Continuous";
  420. }
  421. }
  422. private string GetXMLFormat(ExportIEMStyle style)
  423. {
  424. if (style.Format is NumberFormat || style.Format is CurrencyFormat)
  425. {
  426. return "<NumberFormat ss:Format=\"" + ExportUtils.GetExcelFormatSpecifier(style.Format) + "\"/>\r\n";
  427. }
  428. return String.Empty;
  429. }
  430. #endregion
  431. #region Protected Methods
  432. /// <inheritdoc/>
  433. protected override string GetFileFilter()
  434. {
  435. return new MyRes("FileFilters").Get("XlsFile");
  436. }
  437. /// <inheritdoc/>
  438. protected override void Start()
  439. {
  440. base.Start();
  441. sheets = new Dictionary<string, XMLSheet>();
  442. commonStyles = new List<ExportIEMStyle>();
  443. }
  444. /// <inheritdoc/>
  445. protected override void ExportPageBegin(ReportPage page)
  446. {
  447. base.ExportPageBegin(page);
  448. if (sheets.ContainsKey(page.Name) && !SplitPages)
  449. {
  450. sh = sheets[page.Name] as XMLSheet;
  451. sh.matrix.AddPageBegin(page);
  452. }
  453. else
  454. {
  455. matrix = new ExportMatrix();
  456. if (Wysiwyg)
  457. matrix.Inaccuracy = 0.5f;
  458. else
  459. matrix.Inaccuracy = 10;
  460. matrix.RotatedAsImage = false;
  461. matrix.PlainRich = true;
  462. matrix.AreaFill = true;
  463. matrix.CropAreaFill = true;
  464. matrix.Report = Report;
  465. matrix.Images = false;
  466. matrix.DataOnly = DataOnly;
  467. matrix.ShowProgress = ShowProgress;
  468. matrix.MaxCellHeight = ydivider * xLMaxHeight;
  469. matrix.AddPageBegin(page);
  470. matrix.Styles = commonStyles;
  471. }
  472. }
  473. /// <inheritdoc/>
  474. protected override void ExportBand(BandBase band)
  475. {
  476. base.ExportBand(band);
  477. if (sheets.ContainsKey(band.Page.Name) && !SplitPages)
  478. {
  479. sh = sheets[band.Page.Name];
  480. sh.matrix.AddBand(band, this);
  481. }
  482. else
  483. {
  484. matrix.AddBand(band, this);
  485. }
  486. }
  487. /// <inheritdoc/>
  488. protected override void ExportPageEnd(ReportPage page)
  489. {
  490. if (sheets.ContainsKey(page.Name) && !SplitPages)
  491. {
  492. sh = sheets[page.Name] as XMLSheet;
  493. sh.matrix.AddPageEnd(page);
  494. }
  495. else
  496. {
  497. string new_page_name = page.Name;
  498. if (SplitPages)
  499. {
  500. if (sheets.ContainsKey(page.Name + "-1"))
  501. {
  502. int repeats = 2;
  503. while (sheets.ContainsKey(page.Name + "-" + repeats.ToString()))
  504. repeats++;
  505. new_page_name += "-" + repeats.ToString();
  506. }
  507. else if (Report.PreparedPages.GetPage(sheets.Count + 1) != null &&
  508. Report.PreparedPages.GetPage(sheets.Count + 1).Name == page.Name)
  509. {
  510. new_page_name += "-1";
  511. }
  512. }
  513. matrix.AddPageEnd(page);
  514. sh = new XMLSheet(matrix, new_page_name, pageBreaks);
  515. sheets[new_page_name] = sh;
  516. }
  517. }
  518. /// <inheritdoc/>
  519. protected override void Finish()
  520. {
  521. foreach (XMLSheet sheet in sheets.Values)
  522. sheet.matrix.Prepare();
  523. MyRes Res = new MyRes("Export,Misc");
  524. if (ShowProgress)
  525. Config.ReportSettings.OnProgress(Report, Res.Get("SaveFile"));
  526. ExportXML(Stream);
  527. }
  528. #endregion
  529. /// <inheritdoc/>
  530. public override void Serialize(FRWriter writer)
  531. {
  532. base.Serialize(writer);
  533. writer.WriteBool("Wysiwyg", Wysiwyg);
  534. writer.WriteBool("PageBreaks", PageBreaks);
  535. writer.WriteBool("DataOnly", DataOnly);
  536. writer.WriteBool("SplitPages", SplitPages);
  537. }
  538. /// <summary>
  539. /// Initializes a new instance of the <see cref="XMLExport"/> class.
  540. /// </summary>
  541. public XMLExport()
  542. {
  543. pageBreaks = true;
  544. Wysiwyg = true;
  545. creator = "FastReport";
  546. }
  547. }
  548. }