Explorar el Código

导出Excel微调,计量标表2

TonyKang hace 6 años
padre
commit
d78ed6138b
Se han modificado 1 ficheros con 22 adiciones y 2 borrados
  1. 22 2
      Forms/ReportsFrm.pas

+ 22 - 2
Forms/ReportsFrm.pas

@@ -10,7 +10,7 @@ interface
 uses
   ProjectData, ScFileArchiver, ReportManager, ConditionalDefines,
   PrintComTypeDefUnit, ADODB, DB, ReportPrepare, ReportConnection,
-  AuditSelectFrm,
+  AuditSelectFrm, ExcelOutput, 
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, PrintCom, PrintComXML, ExtCtrls, ExTreeView, ImgList,
   dxBarExtItems, dxBar, ComCtrls, ToolWin, StdCtrls, Jpeg;
@@ -159,6 +159,7 @@ type
     function GetPrecededCount: Integer;
     function GetExcelMode: TOutputExcelMode;
     function GetIsExcel2010: Boolean;
+    function GetSysTempDirectory : String;
   public
     destructor Destroy; override;
     procedure RefreshReportTemplets;
@@ -1460,20 +1461,39 @@ begin
   end;
 end;
 
+function TReportsForm.GetSysTempDirectory : String;
+var TempDir : array[0..255] of Char;
+begin
+  GetTempPath(255, @TempDir);
+  Result := StrPas(TempDir);
+end;
+
 procedure TReportsForm.ExportXlsReport(AStartPage, AEndPage: Integer;
   const AFileName: string; APrintCom: TPrintComXML);
 
   procedure ExportPagesXlsReport(AStartPage, AEndPage: Integer; const AFileName: string);
   var
     Border : TColumnLineRec;
+    themeFile, tmpPath : string;
   begin
     LoadExcelBorder(Border);
     if IsExcel2010 then
+    begin
+      (*
       APrintCom.OutputToExcelFileOE(PreviewBox.Canvas, AStartPage, AEndPage, AFileName, ExcelMode, Border, nil)
-    else
+      (*)
+      //用新方法处理
+      themeFile := ExtractFilePath(Application.ExeName) + 'Data\theme1.xml';
+      tmpPath := GetSysTempDirectory;
+      APrintCom.buildOutputData(PreviewBox.Canvas, AStartPage, AEndPage, Border);
+      ExcelOutput.outputAsExcel(APrintCom.OutputData, APrintCom.PageSize, (excelMode = oemOneSheet), tmpPath, themeFile, AFileName, nil);
+      //*)
+    end else
+    begin
       //APrintCom.OutputToExcelFile(PreviewBox.Canvas, AStartPage, AEndPage, GetTemplateXlsFileName, AFileName, ExcelMode, Border);
       APrintCom.OutputToExcelFileOE(PreviewBox.Canvas, AStartPage, AEndPage, AFileName, ExcelMode, Border, nil);
       //现2010格式与之前格式应用同一控件导出
+    end;
   end;
 
 var