Exporting to excel from Delphi without having excel

后端 未结 8 853

I\'m looking to export data to excel from Delphi without having to own a copy of excel, is this possible?

N.B. CSV will not do.

相关标签:
8条回答
  • 2020-12-24 04:18

    I believe it's possible to create MS Office documents as HTML. You don't need to open them in a web browser then or anything, the file can still have the extension .xls and open in Excel like normal.

    I just created a new spreadsheet and stuck the numbers 1-3 in the first three cells of column A, and saved it as HTML. There was a bunch of extra mess that probably isn't all necessary. I stripped out as much as I could, here's what looks to be the bare minimum to produce a working spreadsheet.

    Try creating a new text file with this as its contents, and save it with a .xls extension.

    <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <!--[if gte mso 9]><xml>
     <x:ExcelWorkbook>
      <x:ExcelWorksheets>
       <x:ExcelWorksheet>
        <x:Name>Sheet1</x:Name>
        <x:WorksheetOptions>
         <x:Selected/>
         <x:Panes>
          <x:Pane>
           <x:Number>3</x:Number>
           <x:ActiveRow>3</x:ActiveRow>
          </x:Pane>
         </x:Panes>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
      </x:ExcelWorksheets>
     </x:ExcelWorkbook>
    </xml><![endif]-->
    </head>
    <body>
    
    <table x:str>
        <tr>
            <td x:num width=64>1</td>
        </tr>
        <tr>
            <td x:num>2</td>
        </tr>
        <tr>
            <td x:num>3</td>
        </tr>
    </table>
    </body>
    </html>
    
    0 讨论(0)
  • 2020-12-24 04:21

    SMExport from Scalabium (scalabium.com) includes lots of formats, including Excel format with or without having Excel installed.

    0 讨论(0)
提交回复
热议问题