Background of this article: Recently, I want to export to Excel via Interface fully controlled data typography format. I don't want to use Variant because of the slow operation, the code is clear, and the EXCEL object hierarchy is clear.
Drop process: The basic operation is simple, I can do Pagesetup and the selected list or one line. Don't look at the code below, I spent a day and a half, search, ask (too dish, embarrassing ...).
This article: Data sharing and expect data sharing.
Procedure autoexcelbyintf; var r: Range; LCID: integer;
// This is the correct type, otherwise you can't find Pagesetup B: _Workbook; s: _Worksheet; Begin ...
LCID: = GetUserDefaultlcid; b: = xlapp.workbooks.add (emptyparam, lcid);
// Two ways one sample // s: = b.Sheets [1] as _Worksheet; s: = b.sheets.Item [1] as _Worksheet;
// Page Setup.pagesetup.Leftmargin: = 150; // Other no longer list ...
// The first column and the first line of text format set // set to Text No. 3.1515926535897932384626 is intermedial 3.14159265358979 // Note: Excel up to 65536 lines, IV column
// xlapp.range ['A1', 'A65536']. Numberformat: = '@'; // Cannot Tolerate this stupid method // xlapp.range ['A1', 'IV1']. Numberformat: = '@' = = '@'; R.ntirelow.numberformat: = '@'; r.entirelow.numberformat: = '@';
...
// Select one hundred lines and one hundred columns // r: = xlapp.range ['A1', 'CV100']; // Cannot tolerate this stupid method // r.select; // Although it can achieve the destination R: = Xlapp.cells; r: = r.range_ [r.item [1, 1], r.item [100, 100]]; r.select;
Thank you for your brick! :-)