Creating a file in Microsoft Excel format

Here is a sample template using EXCEL commands:

Cell

Formula

Explanation

A1

 

Enter Part Number via Keyboard.

B1

EXCEL_CREATE "c:\monthly_report.xls" :

IF (EXCEL_ERROR > 0),
(MESSAGE EXCEL_ERRORDESC, (CONCAT "Error number ", EXCEL_ERROR))
+ GOTO [A1]

Create the file.

If the file cannot be created, display the error number and the error message, and then return to cell [A1].

C1

EXCEL_SETCOLW 1, 1, 30 :
EXCEL_SETCOLW 2, 3, 15

Set the width of column A to' 30' and widths of columns B and C to '15'.

D1

EXCEL_SETMARGIN 38, 1 :
EXCEL_SETMARGIN 39, 1

Set left and right margins to one inch.

E1

EXCEL_SETMISC 1, "Monthly Report"

Set the Header.

F1

EXCEL_WRITE 2, 0, 0, 1, 1, (STAT_STR 10) :
EXCEL_WRITE 2, 0, 0, 1, 2, DESCRIPTION :
EXCEL_WRITE 2, 0, 0, 3, 1, “Lower Spec” :
EXCEL_WRITE 2, 0, 0, 4, 1, “Upper Spec” :
EXCEL_WRITE 2, 0, 0, 5, 1, “Spec target” :
EXCEL_WRITE 2, 0, 0, 6, 1, “Spec tolerance (lower)” :
EXCEL_WRITE 2, 0, 0, 7, 1, “Spec tolerance (upper)” :
EXCEL_WRITE 2, 0, 0, 8, 1, “Mean” :
EXCEL_WRITE 2, 0, 0, 9, 1, “Cpk”

Write values to the file - Part Number and Description in the first row and labels in column 1.

G1

EXCEL_WRITE 1, 0, 0, 3, 2, LOWERSPEC :
EXCEL_WRITE 1, 0, 0, 4, 2, UPPERSPEC :
EXCEL_WRITE 1, 0, 0, 5, 2, (STAT_STR 44) :
EXCEL_WRITE 1, 0, 0, 8, 2, (STAT_STR 23) :
EXCEL_WRITE 1, 0, 0, 9, 2, (STAT_STR 121)

Write the actual statistical values in column 2.

We will later add Excel formulas to calculate the Spec tolerances.

H1

EXCEL_CLOSE

Close the file

I1

EXCELCOM_OPEN "c:\monthly_report.xls"

Open the file for modification.

J1

EXCELCOM_WRITE 6, 2, "=B5-B3" :
EXCELCOM_WRITE 7, 2, "=B4-B5"

Enter Excel formulas to calculate the Spec tolerances.

K1

EXCELCOM_CLOSE

Close the file.

L1

RUNANDWAIT "C:\Program Files\Microsoft Office\Office\excel.exe c:\monthly_report.xls"

Launch the file in Excel

M1

EXIT

Exit out of the template