翻譯|使用教程|編輯:李顯亮|2020-06-01 10:39:11.180|閱讀 744 次
概述:XML是一項旨在管理結構化數據并將該數據顯示為人類可讀的文本文件的技術。FastReport允許以多種格式保存來自Delphi和Lazarus的文檔,報告和數據。本文將講解如何從Delphi / Lazarus將報表導出到Excel XML。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
報表生成器FastReport VCL是用于在軟件中集成商務智能的現代解決方案。它提供了可視化模板設計器,可以訪問最受歡迎的數據源,報告引擎,預覽,將過濾器導出為30多種格式,并可以部署到云,Web,電子郵件和打印中。
近日,FastReport VCL更新至v6.7,在新版本中,添加了對最新版本IDE的支持,簡化了用于付款標準的條形碼的創建,新增從預覽窗口直接編輯RichView的功能,同時修復了多個Bug問題。歡迎下載體驗。(點擊下方按鈕下載)
XML是一項旨在管理結構化數據并將該數據顯示為人類可讀的文本文件的技術。XML符合行業標準,可以被許多數據庫和應用程序處理。使用XML,許多開發人員可以創建自己的自定義標簽,數據結構和架構。通常,XML極大地促進了各種數據庫,應用程序和組織中數據的定義,傳輸,驗證和解釋。
但是,如果微軟傳統上不嘗試制作“擁有二十一點和單元的自己的XML”,那微軟就不會成為自己。因此,Excel實際上不是使用一種(?。ML標準來存儲Excel電子表格,而是一種(較舊的和更正確的)XML標準。
正如多次提到的,FastReport允許以各種格式保存來自Delphi和Lazarus的文檔、報告和數據。唯一想指出的是,我們需要觀察對象的對齊方式,以便生成的電子表格具有吸引力和質量。因此,Fastreport為Excel XML提供了兩個不同的(!)導出過濾器。
很明顯,程序員從來不會做任何“僅僅因為他想做”的事情——用戶才是真正想做什么的人。那么,從用戶的角度來看,當他想從應用程序獲得Excel電子表格時,這兩種格式有什么不同呢?
對于用戶來說,這種差異與沒有任何圖片的rtf和成熟的MS Word文檔之間的差異大致相同——第一個差異在現實生活中很少出現。在一個簡單的XML文件中沒有樣式或圖片—只有一個XML表。
FastReport工具可幫助選擇將文檔的哪些頁面發送到Excel,某些頁面或范圍。 導出設置:與原始版本(WYSIWYG)更好的視覺對應,分頁符和跳過頁眉和頁腳的連續文檔。
結果:不要拆分,使用報告頁面,在父級上使用打印-報告模板中的每個TrfxReportPage都對應于該書的一張紙(假設TfrxReportPage.PrintOnParent = False)或按特殊數量拆分行。導出后打開:導出后,Microsoft Excel將立即打開結果文件(或由與XLSX文件關聯的任何其他軟件)打開。
可以將生成的XML / XLSX保存為本地存儲中帶有.xml擴展名的文件,發送到FTP,通過電子郵件發送或上傳到其中一個云存儲(Dropbox,OneDrive,Box.com,GoogleDrive)。
比較生成的XLSX和Excel XML文件
第一個屏幕截圖是保存為XLSX格式的結果,并且我們可以看到,該格式不支持比純文本更復雜的數據。但是第二張屏幕截圖向我們展示了XML格式的所有可能性,例如完全支持圖像和條形碼。說到文件的重量,結果是可以預料的:XLSX-48,0kB,XML-40,0kB。
讓我們進一步了解為什么XLSX比XML更重要。這些美麗的魚被作為基礎。這份文件包含了大量的文本、表格數據和30張照片。為了更清楚地說明問題,讓我們將其與未老化的Excel 97進行比較,我們在另一篇文章中討論過它。
Excel 97 –它是二進制格式(biff8),沒有任何壓縮,因此文件很大。與后來的XML格式不同,Excel 97支持各種圖像。Excel table(XML)– XLSX的早期版本,其中的數據存儲為簡單,單個,整體的XML文件,與OOXML和MS Office傳統二進制格式相比,它們非常大。
Excel 97 –它是二進制格式(biff8),沒有任何壓縮,因此文件很大。與后來的XML格式不同,Excel 97支持各種圖像。Excel table(XML)– XLSX的早期版本,其中的數據存儲為簡單,單個,整體的XML文件,與OOXML和MS Office傳統二進制格式相比,它們非常大。
XLSX Excel 2007格式的有限功能和可能的限制
列數從256增加到16 384,工作表中的行數從65 536增加到1,048576。由于Excel 2007支持多個處理器和多線程芯片組,因此具有許多公式的大工作表計算得以加速。
如何直接從Delphi / Lazarus中保存到XLSX和XML Excel中
導出到XML
procedure TForm1.Button1Click(Sender: TObject); begin {Generate a report. The report must be generated before exporting} frxReport1.PrepareReport(); {Set the range of pages to export. By default, all pages of the generated report are exported} frxXMLExport1.PageNumbers := '2-3'; {Set whether to generate a continuous document which skips headers and footers. Enabling this option disables TfrxXMLExport.ExportPageBreaks} frxXMLExport1.SuppressPageHeadersFooters := True; {Set whether to export the page breaks within the sheet of the book so that when printing the pages correspond to the pages of the generated report} frxXMLExport1.ExportPageBreaks := True; {Set WYSIWYG} frxXMLExport1.Wysiwyg := True; {Set the document splitting order using Split property which can take the following values: ssNotSplit – create a continuous document; ssRPages – each sheet of the generated report corresponds to the sheet of the book; ssPrintOnPrev – each sheet of TfrxReportPage in the report template corresponds to a sheet of the book (provided that TfrxReportPage.PrintOnParent = False); ssRowsCount - each sheet will have the number of rows specified in the TfrxXMLExport.RowsCount property.} frxXMLExport1.Split := ssNotSplit; {Set whether to open the resulting file after export} frxXMLExport1.OpenAfterExport := False; {Set whether to display export progress (show which page is currently being exported)} frxXMLExport1.ShowProgress := False; {Set whether to display a dialog box with export filter settings} frxXMLExport1.ShowDialog := False; {Set the name of the resulting file.} {Please note that if you do not set the file name and disable the export filter dialog box,} {the file name selection dialog will still be displayed} frxXMLExport1.FileName := 'C:\Output\test.xls'; {Export the report} frxReport1.Export(frxXMLExport1); end;
導出到XLSX
procedure TForm1.Button2Click(Sender: TObject); begin {Generate a report. The report must be generated before exporting} frxReport1.PrepareReport(); {Set the range of pages to export. By default, all pages of the generated report are exported} frxXLSXExport1.PageNumbers := '2-3'; {Set whether to generate a continuous document which skips empty rows, headers and footers (with EmptyLines = False). With EmptyLines = True the report will be exported as it was generated. Without skipping the empty rows, headers and footers. Enabling this option disables TfrxXLSXExport.SuppressPageHeadersFooters and vice versa) frxXLSXExport1.EmptyLines := True; {Set whether to export the page breaks within the sheet of the book so that when printing the pages correspond to the pages of the generated report} frxXLSXExport1.ExportPageBreaks := True; {Set WYSIWYG} frxXLSXExport1.Wysiwyg := True; {Set whether to export only the content of data bands} frxXLSXExport1.DataOnly := False; {Set the document splitting order: with the SingleSheet option on, all pages of the document will be located on one sheet frxXLSXExport1.SingleSheet := True; If you set the value to ChunkSize, each sheet will have a specified number of rows. In this case SingleSheet should be set to False frxXLSXExport1.ChunkSize := 50; We will set the default order when each sheet of the generated report corresponds to a sheet of the book} frxXLSXExport1.SingleSheet := False; frxXLSXExport1.ChunkSize := 0; {Set whether to open the resulting file after export} frxXLSXExport1.OpenAfterExport := False; {Set whether to display export progress (show which page is currently being exported)} frxXLSXExport1.ShowProgress := False; {Set whether to display a dialog box with export filter settings} frxXLSXExport1.ShowDialog := False; {Set the name of the resulting file.} {Please note that if you do not set the file name and disable the export filter dialog box,} {the file name selection dialog will still be displayed} frxXLSXExport1.FileName := 'C:\Output\test.xlsx'; {Export the report} frxReport1.Export(frxXLSXExport1); end;
還想要更多嗎?您可以點擊閱讀【FastReport 報表2019最新資源盤點】,查找需要的教程資源。如果您有任何疑問或需求,請隨時加入FastReport技術交流群(783996712),我們很高興為您提供查詢和咨詢。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn