2017年12月7日 星期四

VFP 的報表資料

最近,因為工作需要,必需把原來用 VFP 開發的程式,轉移成 PHP 的網頁程式。使用 VFP 設計的報表,也必須改寫成網頁,藉以輸出 PDF 檔。但是使用 PHP,能想到的解決方式,就是輸入一堆座標數字,然後,用程式在對應的位置畫表格,輸出文字或資料。要一一重新決定位置或欄位的資料,是非常累人的工作。最快的方法是把 VFP 的報表設計的資料直接撈出來,轉成程式資料,然後在 PHP 中,使用 PDF 指令,把它輸出到報表 。

還好,已經有人費心的挖掘出 VFP 報表的資料表達方式,可參見下列的討論
Is it possible to open a File .FRT/FRX in MS Excel or MS Access

VFP 報表的資料,是存在 dbf 中,只是附檔名不同而已,可以使用 USE 直接開啟,讀取其中的資料。檔案結構的說明,請參見: .FRX and .LBX Table Structure for Visual FoxPro for Windows



Crystal Report 與 pdf 的度量單位

Crystal Report 的單位為 TWIPS (twentieth of a point) [http://en.wikipedia.org/wiki/Twip], 1 twip = 1/1440 inch, they are independent of the number of pixels on the screen; to find out how many twips wide your document is, you check the page size you setup on the report (in inches let’s say, then multiply by 1440). And I’m not sure you can change this programmatically.

Anyway: if 1 inch = 1440 twips, 1 cm = 576 twips.

PDF 的單位如下,AbcPdf 也可設成 twips
This property holds the current measurement units. This property can take any of the following values:

points (PostScript Points) - 1/72 of an Inch
twips (Twentieths of a Point) - 1/20 of a PostScript Point

另外,PDF 的座標的原點在左下角,AbcPdf 可以設成由上往下。

電腦字型, 例如 14,轉換成 twips 為 14*20。

網誌存檔