hi,
> It works for 1-Dim if AADD(aExcel,{i}).
yes, thx
> But your sample shows how speed up things. However
to create a XLS file I
> need know formating too.
i´m not a Excel User, so most of it i do not know
how to do it in Excel.
but i know activeX, so i just use Excel Methode and
Property which
you can find in VBA-Help File. my (German) File is
called
"C:\Programme\Microsoft
Office\Office10\1031\VBAXL10.CHM"
i general : every Xbase++ activeX call need time ...
about 0.20-0.40sec
so allways try to "transfer maximum" with 1 activeX
call like a hole Array
> Here are some basic needs:
> * Put color of text line.
> * Define a backgound color for a line.
look at
FONT() Object Property
> * Define column width
oSheet:Columns( nNumber
):ColumnWidth := 5.5 (mm)
> * Fornat numeric column (right aligned with
thousand separator an 2
> decimals)
oSheet:Columns("F
"):NumberFormatLocal
oSheet:Columns("F
"):NumberFormat :=
"$#,##0.00_);[Red]($#,##0.00)"
> * Totalize numeric column
you can put a "Fomula" into Array when pass to
Excel
aExcel[PosKG] [myGEWICHT] := "=SUMME(D4:K4)" //
German SUMME
> * Save in old xls format (97/2003)
look at
:SaveAs FileFormat Constante in
Excel.CH (Demo Sample)
here some more Sample :
if you want "to make something" with a hole
Columne
use
:Columns()
oSheet
:Columns("A"):HorizontalAlignment := xlLeft
oSheet
:Columns("F"):HorizontalAlignment := xlRight
oSheet
:Columns("G"):HorizontalAlignment := xlRight
oSheet
:Columns("J"):HorizontalAlignment :=
xlRight
dito use
:Rows() for hole Row
5 Rows setting Font etc.
* i
:= 1
* FOR i := 1
TO 5
*
cZeile := LTRIM(STR(i))
*
DO CASE
*
CASE i = 1
*
oSheet:range( "A"+cZeile+":J"+cZeile ):Font():Size := 18
*
CASE i = 2
*
oSheet:range( "A"+cZeile+":J"+cZeile ):Font():Size := 14
*
CASE i = 3
*
oSheet:range( "A"+cZeile+":J"+cZeile ):Font():Size := 14
*
CASE i = 4
*
oSheet:range( "A"+cZeile+":J"+cZeile ):Font():Size := 14
*
CASE i = 5
*
oSheet:range( "A"+cZeile+":J"+cZeile ):Font():Size := 14
*
ENDCASE
*
*
oSheet:range( "A"+cZeile+":J"+cZeile ):Font():Name := "Times" /
*
oSheet:range( "A"+cZeile+":J"+cZeile ):Font():Bold := .t.
* NEXT
oZeile := oSheet
:range( "A1:J1" ):Font()
oZeile:Size := 18 //Schriftgrösse
ändern
oZeile:Name := "Times" //Schrift festlegen
oZeile:Bold := .T.
oZeile := oSheet
:range( "A2:J5" ):Font()
oZeile:Size := 14 //Schriftgrösse
ändern
oZeile:Name := "Times" //Schrift festlegen
oZeile:Bold := .T.
* old "slow" Version vs. "fast" Range()
Version
//
// later use
Macro
//
cRange := ""
//
// Array
Number Header-Line
//
i := 1
iMax :=
LEN(aHeaderLine)
//
FOR i := 1
TO iMax
cZeile := LTRIM(STR(aHeaderLine[i]))
*
* old Version did it Line-by-Line ... "very
slow"
*
*
oZeile := oSheet:range( "A"+cZeile+":J"+cZeile ):Font()
cRange := cRange+"A"+cZeile+":J"+cZeile
//
// seem there is a limitation in LEN(cRange) about 256 ???
//
//
//
IF LEN(cRange) > 256-16
//
// now use macro &(cRange)
//
cRange := CHR(34)+cRange+CHR(34)
oSheet
:range( &(cRange) ):Font():Size := 18
oSheet
:range( &(cRange) ):Font():Name := "Times"
oSheet
:range( &(cRange) ):Font():Bold := .t.
//
// reset
cRange := ""
ELSE
IF i <> iMax
//
// add "Komma" .. this is what help file say, BUT
// ist does NOT work ( German OS() ? ) so i try
// & Error until it works with
";"
//
cRange := cRange+
";"
ELSE
//
// now use macro &(cRange)
//
cRange := CHR(34)+cRange+CHR(34)
oSheet:range( &(cRange) ):Font():Size := 18
oSheet:range( &(cRange) ):Font():Name := "Times"
oSheet:range( &(cRange) ):Font():Bold := .t.
ENDIF
ENDIF
NEXT
Question : how to "translate" this :
Worksheets("Sheet1").Activate
Range(
Cells(1, 1),
Cells(5, 3)).Font.Italic = True
greetings by OHR
Jimmy