Hi, Am using this technique to convert on daily basis a bulk number of reports ( clients statements ) extracted from a single DBF table then distributed into different type of PDF documents to be emailed later on to customers. the entire process of accounts distribution is automated with a single click. if you look at my code below you will notice that i am converting the DBF to excel first before saving it as PDF!. my question is there is a more simple way to do the task which is converting directly to PDF without a middle agent ( Excel in this case ) In Between.
< Code >
WAIT WINDOW "Please Wait ... Generating PDF-Files." NOWA
&& Initiate Excel
oExcel = CreateObject("Excel.Application")
if vartype(oExcel) != "O"
return .F.
ENDIF
oExcel.DisplayAlerts = .F.
oExcel.Application.UserControl=.F.
oExcel.visible = .T.
oWorkbook = oExcel.Application.Workbooks.Add() && Add New Workbook <Book1>
#define xlTypePDF 0 && PDF Extension
&&
SELECT 1 && Pre-Prepared Accounts Table For Customers. Strip Statement Suitable For Mobile Screen View
GO TOP
DO WHILE NOT EOF()
&& Read Data
ACCCNUM = ALLTRIM(ACC_CNUM)
ACCNAME = ALLTRIM(ACC_NAME)
WAIT WINDOW "Generating {" + ACCCNUM + "}-{" + ACCNAME + "}" NOWA
&&
&& Send To Temporal Table
SELECT 2
SET FILTER TO ALLTRIM(AGENT_ID) = ACCCNUM
COPY TO TMPDIR + "EXPORT2.DBF"
&&
&& Transfer To Excel -> PDF
SELECT 3
USE TMPDIR + "EXPORT2.DBF"
IF RECCOUNT() > 0 && Automate
oSheet = oExcel.ActiveSheet
oSheet.Columns("A:A").ColumnWidth=41
oSheet.Columns("B:B").ColumnWidth=26
oSheet.Columns("A:A").Font.Name = "Calibri"
oSheet.Columns("A:A").Font.Size = 24
oSheet.Columns("B:B").Font.Name = "Calibri"
oSheet.Columns("B:B").Font.Size = 24
XCOUNT = 0
GO TOP
DO WHILE NOT EOF()
XCOUNT = XCOUNT + 1
VAR001 = D_ETAILS
VAR002 = A_MOUNT
XCELL1 = "A" + ALLTRIM(STR(XCOUNT))
XCELL2 = "B" + ALLTRIM(STR(XCOUNT))
oExcel.Range(XCELL1).Value = VAR001
oExcel.Range(XCELL2).Value = VAR002
SKIP + 1
ENDDO
FileName1 = "C:\ABC\" + ACCCNUM
oWorkbook.ExportAsFixedFormat(xlTypePDF,FileName1)
ENDIF
USE
&&
&& Clear The Excel Sheet
oExcel.Range("A1:B1500").Clear && Clear The Excel Sheet
&&
SELECT 1
SKIP + 1
ENDDO
oExcel.quit()
oExcel = .Null.
RELEASE oExcel
WAIT WINDOW "Ready." NOWA
CLOSE DATABASES ALL
MESSAGEBOX("PDF Files Successfully Generated.",64,"Message")
RETURN
< Code>
< Code >
WAIT WINDOW "Please Wait ... Generating PDF-Files." NOWA
&& Initiate Excel
oExcel = CreateObject("Excel.Application")
if vartype(oExcel) != "O"
return .F.
ENDIF
oExcel.DisplayAlerts = .F.
oExcel.Application.UserControl=.F.
oExcel.visible = .T.
oWorkbook = oExcel.Application.Workbooks.Add() && Add New Workbook <Book1>
#define xlTypePDF 0 && PDF Extension
&&
SELECT 1 && Pre-Prepared Accounts Table For Customers. Strip Statement Suitable For Mobile Screen View
GO TOP
DO WHILE NOT EOF()
&& Read Data
ACCCNUM = ALLTRIM(ACC_CNUM)
ACCNAME = ALLTRIM(ACC_NAME)
WAIT WINDOW "Generating {" + ACCCNUM + "}-{" + ACCNAME + "}" NOWA
&&
&& Send To Temporal Table
SELECT 2
SET FILTER TO ALLTRIM(AGENT_ID) = ACCCNUM
COPY TO TMPDIR + "EXPORT2.DBF"
&&
&& Transfer To Excel -> PDF
SELECT 3
USE TMPDIR + "EXPORT2.DBF"
IF RECCOUNT() > 0 && Automate
oSheet = oExcel.ActiveSheet
oSheet.Columns("A:A").ColumnWidth=41
oSheet.Columns("B:B").ColumnWidth=26
oSheet.Columns("A:A").Font.Name = "Calibri"
oSheet.Columns("A:A").Font.Size = 24
oSheet.Columns("B:B").Font.Name = "Calibri"
oSheet.Columns("B:B").Font.Size = 24
XCOUNT = 0
GO TOP
DO WHILE NOT EOF()
XCOUNT = XCOUNT + 1
VAR001 = D_ETAILS
VAR002 = A_MOUNT
XCELL1 = "A" + ALLTRIM(STR(XCOUNT))
XCELL2 = "B" + ALLTRIM(STR(XCOUNT))
oExcel.Range(XCELL1).Value = VAR001
oExcel.Range(XCELL2).Value = VAR002
SKIP + 1
ENDDO
FileName1 = "C:\ABC\" + ACCCNUM
oWorkbook.ExportAsFixedFormat(xlTypePDF,FileName1)
ENDIF
USE
&&
&& Clear The Excel Sheet
oExcel.Range("A1:B1500").Clear && Clear The Excel Sheet
&&
SELECT 1
SKIP + 1
ENDDO
oExcel.quit()
oExcel = .Null.
RELEASE oExcel
WAIT WINDOW "Ready." NOWA
CLOSE DATABASES ALL
MESSAGEBOX("PDF Files Successfully Generated.",64,"Message")
RETURN
< Code>