Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Export Excel Workbook to .PDF
Message
De
14/01/2018 03:12:31
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
13/01/2018 14:16:31
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01657177
Message ID:
01657186
Vues:
86
This message has been marked as the solution to the initial question of the thread.
>
>
>            string xlsfilename = ConfigurationManager.AppSettings["XLSFilesPath"] + "ps20180113.xls";
>            string pdffilename = ConfigurationManager.AppSettings["PDFFilesPath"] + "testps20180113.pdf";
>
>            Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
>            Microsoft.Office.Interop.Excel.Workbook wbv = excel.Workbooks.Open(xlsfilename);
>            Microsoft.Office.Interop.Excel.Worksheet wx = excel.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;
>            if (File.Exists(pdffilename))
>            {
>                File.Delete(pdffilename);
>            }
>
>            wbv.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, pdffilename);
>
>       
>            wbv.Close(true, Type.Missing, Type.Missing);
>            excel.Quit();
>
>
>The above C# code creates a .pdf from an Excel Worksheet
>I can't find the equivalent code to do it with VFP

Assuming you can use automation, you don't need no friggin interop - the ugly kludge of a word was meant to bridge the gap between dot-nyet stuff (i.e. c#) and other stuff (i.e. office, which is still not rewritten in dot net, after 17 years)
So something like
oEx=createobject("excel.application")
oWb=oEx.Workbooks.Open(xlsfilename)
oSh=oEx.ActiveSheet
if File(pdffilename)
              erase (pdffilename)
endif
oSh.ExportAsFixedFormat(oEx.XlFixedFormatType.xlTypePDF, pdffilename)
OWb.Close(0)
oEx.quit()
As for the special locations... I assume you have your own locations, or can find how to extract them from Excel or wherever they are defined.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform