LibXL und Zellen umranden

Moderator: Moderatoren

Antworten
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo,
wie kann ich einer Zelle ein bestimmtes Format zuordenen ? Ich möchte eine Zelle dick unterstreichen, also setBorderBottom(BORDERSTYLE_THICK). Aber wie addressiere ich die Zelle ?
Grüße
Rudolf
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

schau dir mal meine Klasse an ... ansonsten 0,0 ist A1 ... wenn ich mich richtig erinnere
Gruß
Hubert
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo Hubert,
in der Klasse sehe ich auch nicht wo die Position angegeben wird.
Grüße
Rudolf


METHOD xlFormat:FormatSetBorderBottom( nStyle )
LOCAL uRet := nil
DEFAULT nStyle TO 0
uRet := FpQCall( {'LibXL','xlFormatSetBorderBottomA'},'__vo__sl__sl',::hHandle,nStyle)
RETURN uRet
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo,
wenn ich das Format vorher mit

oFormatLine := oBook:BookaddFormat()
oFormatLine:FormatsetBorderBottom(BORDERSTYLE_THICK)

defniere und dann z.B.

for zz := 1 to 27
oSheet:SheetsetCol(nLine,zz-1,,oFormatLine)
next zz

formatiere habe ich keinen dicken Strich unten und die Zelle hat die Breite 0 bekommen :-(
Grüße
Rudolf
Benutzeravatar
Werner_Bayern
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
Beiträge: 2120
Registriert: Sa, 30. Jan 2010 22:58
Wohnort: Niederbayern
Hat sich bedankt: 29 Mal
Danksagung erhalten: 70 Mal

Re: LibXL und Zellen umranden

Beitrag von Werner_Bayern »

Code: Alles auswählen

Excel_SheetWriteNum(nSheet, i + nIndex, i2, val(substr(aDaten[i, i2 + 1], 7)), Excel_SetNumFormat(nFormatHandleDate, NUMFORMAT_DATE))
Einfach aus meinem Code rausgenommen. Du musst das Format beim Schreiben mitgeben.
es grüßt

Werner

<when the music is over, turn off the lights!>
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo Werner,
ich muss in eine Vorlage schreiben und daher das Format nachträglich ändern. Es muss doch einen Möglichkeit geben Zellen zu formatieren ohne dass man was reinschreibt.
Grüße
Rudolf
Benutzeravatar
Werner_Bayern
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
Beiträge: 2120
Registriert: Sa, 30. Jan 2010 22:58
Wohnort: Niederbayern
Hat sich bedankt: 29 Mal
Danksagung erhalten: 70 Mal

Re: LibXL und Zellen umranden

Beitrag von Werner_Bayern »

Servus Rudolf,

m. W. n. nicht. Auch die Beispiele schreiben immer gleichzeitig den Wert.

Lies halt den Wert aus und schreib ihn mit dem neuen Format rein.
es grüßt

Werner

<when the music is over, turn off the lights!>
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo Werner,
das geht nur bei einfachen Formatierungen z.B. fürs Zahlenformat, aber nicht wenn verschiedene Dinge wie Farbe oder Font anders sind. Ich verliere auch Formatierungen wenn ich in eine Zelle schreibe. Mal schauen ob ich vom Support Infos bekomme.
Grüße
Rudolf
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

Rudolf hat geschrieben: Mo, 27. Nov 2017 17:33 Hallo,
wenn ich das Format vorher mit

oFormatLine := oBook:BookaddFormat()
oFormatLine:FormatsetBorderBottom(BORDERSTYLE_THICK)

defniere und dann z.B.

for zz := 1 to 27
oSheet:SheetsetCol(nLine,zz-1,,oFormatLine)
next zz

formatiere habe ich keinen dicken Strich unten und die Zelle hat die Breite 0 bekommen :-(
Grüße
Rudolf
du darfst in deinem Beispiel den 3. Parameter (Spaltenbreite) nicht einfach leer lassen, leer ist soviel wie 0
Richtig ist, dass man entweder ein neues Format anlegt oder das der Zelle abfragt, ändert und wieder setzt.
Gruß
Hubert
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo Hubert,
das habe ich schon korrigiert, muss also vorher die Breite auslesen und dann wieder angeben. Aber die Zelle wird trotzdem nicht unten dick dargestellt. Irgend etwas fehlt noch.
Grüße
Rudolf
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

So wie ich das sehe scheint es keinen Befehl zu geben, der einen normalen Bereich (Excel Range) formatiert.
Die Spalte kann nach unten ja sehr lange sein !
Vermutlich muss man Zelle für Zelle auslesen und links oben, links, links unten, unten, rechts unten, rechts, rechts oben und oben einzeln setzen.

Am Besten mal den support mit dem gewünschten Beispiel fragen, wie man das hin bekommt.
Gruß
Hubert
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

so sähe das wohl in Excel Macro Sprache aus:

Code: Alles auswählen

Sub Makro1()
'
' Makro1 Makro
'

'
    Range("B2").Select
    ActiveCell.FormulaR1C1 = "Test"
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "or"
    Range("B5").Select
    ActiveCell.FormulaR1C1 = "lu"
    Range("C5").Select
    ActiveCell.FormulaR1C1 = "ru"
    Range("B2:C5").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    Selection.Borders(xlEdgeLeft).LineStyle = xlNone
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Selection.Borders(xlEdgeRight).LineStyle = xlNone
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlMedium
    End With
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Range("H12").Select
End Sub
Dateianhänge
Mappe1.xlsx
(8.95 KiB) 299-mal heruntergeladen
Gruß
Hubert
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo Hubert,
danke für die Infos, wäre eigenartig wenn das nicht funktionieren würde, mal schauen was der Support sagt.
Grüße
Rudolf
Benutzeravatar
engindenizoglu
Cut&Paste-Entwickler
Cut&Paste-Entwickler
Beiträge: 41
Registriert: Mi, 08. Nov 2017 20:58
Wohnort: ISTANBUL

LibXL LIBRARY - commands

Beitrag von engindenizoglu »

I started new working with this library.
LIBXL is great library for preparing EXCEL sheets but the samples/documantation for xbase are too much insufficient.

See below a sample:
How can i change the color a certain cell ?
How can i format a cell like 999,999.99 for numbers ?
Does anyone have sample prgs related LIBXL for XBASE++ ?

---------------------------------------------------------------------------------------------------------------------------------------------------------

Code: Alles auswählen

   cFile := "PERSON"                //   EXCEL DOSYA ADI 
   oBook := xlCreateBook(cName,cKey)
    oSheet := oBook:BookAddSheet("SAYFA-1" )            
    now := 1        
    oSheet:SheetWriteStr(now,1,"VORNAME" )           
    oSheet:SheetWriteStr(now,2,"GEHALT " )       ----->   [b]how can i change the cell color[/b]
    oSheet:SheetWriteStr(now,3,"Fiili Çalışma Saat    " )               
     now=now+1
     SAYI=456366.88
     oSheet:SheetWriteNum( now, 8, SAYI)                        ---------->   [b]HOW CAN WE FORMAT THE nr  like 999,999.99  [/b]
---------------------------------------------------------------------------------------------
ENGIN RENE D.

LARA ltd
http:\\www.laraelectromechanical.com
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

Hi,

I wrote the Xbase++ Class HBLibXL, and I think this ist the code from my example:

Code: Alles auswählen

oSheet:SheetWriteStr(now,2,"GEHALT " )       ----->   [b]how can i change the cell color[/b]
oSheet:SheetWriteNum( now, 8, SAYI)     ---------->   [b]HOW CAN WE FORMAT THE nr  like 999,999.99  [/b]
In the example PRGs are examples for color and numeric or date formates.
First you should get the newest version of my class, and look here for more examples:

:arrow: viewtopic.php?f=16&t=7610&p=107692

The first step is to get a format object, with one of 2 ways:
1. oAlign := oBook:BookAddFormat() to add a new format to the book, you can set and access through oAline in this example, or
2. oFormat := oSheet:SheetCellFormat(2,0) to read the active format of a cell, change it an use it !

In Test3.PRG I do use formats directly to write the right format per data type

Code: Alles auswählen

      for k := 1 to nDataCols
         oAlign  := oBook:BookAddFormat()
         oHeader := oBook:BookAddFormat()
         oHeader:FormatSetNumFormat( NUMFORMAT_TEXT )
         oHeader:FormatSetFont( oFont )
         oHeader:FormatSetFillPattern( FILLPATTERN_SOLID )
         oHeader:FormatSetPatternForegroundColor( COLOR_LIGHTGREEN )

         xValue := aData[1,k]
         do case
         case ValType( xValue ) == "C"
            oAlign:FormatSetAlignH( ALIGNH_LEFT )
            oHeader:FormatSetAlignH( ALIGNH_LEFT )
         case ValType( xValue ) == "N"
            oAlign:FormatSetAlignH( ALIGNH_RIGHT )
//          oAlign:FormatSetNumFormat( NUMFORMAT_NUMBER_SEP_D2 )
            oAlign:FormatSetNumFormat( oBook:BookAddCustomNumFormat( "###,###,###.000" ) )
            oHeader:FormatSetAlignH( ALIGNH_RIGHT )
         case ValType( xValue ) == "D"
            oAlign:FormatSetAlignH( ALIGNH_CENTER )
            oAlign:FormatSetNumFormat( NUMFORMAT_DATE )
            oHeader:FormatSetAlignH( ALIGNH_CENTER )
         endcase
         oSheet:SheetSetCol( k-1, k-1, aWidth[k], oAlign )
         oSheet:SheetWriteStr( nRow, k-1, aHeader[k], oHeader )
         oAlign  := NIL
         oHeader := NIL
      next
Dateianhänge
ReadMe.pdf
the newest ReadMe.PDF from HBLibXL 1.10
(25.49 KiB) 301-mal heruntergeladen
Gruß
Hubert
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo,
habe die Antwort vom Support, so müsste es klappen:

You should copy existing formats and add new properties, for example:

Format* oldFormat = sheet->cellFormat(row, col); // get existing format
Format* newFormat = book->addFormat(oldFormat); // copy of oldFormat
newFormat->setBorderBottom(BORDERSTYLE_THICK); // add a new property
sheet->setCellFormat(row, col, newFormat); // set a new format

Grüße
Rudolf
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

Aber eben nur je Zelle, damit braucht man für einen Bereich eine Schleife ...
Gruß
Hubert
Benutzeravatar
Rudolf
Programmier-Gott
Programmier-Gott
Beiträge: 1418
Registriert: Mo, 02. Jan 2006 23:03
Wohnort: Salzburg/Österreich
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von Rudolf »

Hallo,
so löse ich jetzt mein Problem:

Grüße
Rudolf

Code: Alles auswählen

for zz := 1 to 28
       oOld := oSheet:SheetCellFormat(nStart+nLine,zz-1)
      oNew := oBook:BookaddFormat(oOld)
       oNew:FormatsetBorderBottom(BORDERSTYLE_THICK)
        oSheet:SheetSetCellFormat(nStart+nLine,zz-1,oNew)
  next zz
Benutzeravatar
engindenizoglu
Cut&Paste-Entwickler
Cut&Paste-Entwickler
Beiträge: 41
Registriert: Mi, 08. Nov 2017 20:58
Wohnort: ISTANBUL

Re: LibXL - SELECTING FONT

Beitrag von engindenizoglu »

How is it possible to switch to BOLD font ?

-------------------------------------------------------------------------------

Code: Alles auswählen

oFont1:=oBook:BookAddFont() // reuse object is OK.
oFont1:FontSetName("Tahoma")
oFont1:FontSetSize(11)
-------------------------------------------------------------------------------

Here below it saves the excel file , but with which function can i open the same excel file ?

-----------------------------------------------------------------------------

Code: Alles auswählen

 oBook:BookSave( cFile )         /*    rec.     */  
 oBook:destroy()
-----------------------------------------------------------------------------
ENGIN RENE D.

LARA ltd
http:\\www.laraelectromechanical.com
Benutzeravatar
AUGE_OHR
Marvin
Marvin
Beiträge: 12903
Registriert: Do, 16. Mär 2006 7:55
Wohnort: Hamburg
Hat sich bedankt: 19 Mal
Danksagung erhalten: 44 Mal

Re: LibXL - SELECTING FONT

Beitrag von AUGE_OHR »

engindenizoglu hat geschrieben: Fr, 01. Dez 2017 20:52 Here below it saves the excel file , but with which function can i open the same excel file ?
-----------------------------------------------------------------------------

Code: Alles auswählen

 oBook:BookSave( cFile )         /*    rec.     */  
 oBook:destroy()
-----------------------------------------------------------------------------
this is for Excel activeX but here we talk about LibXL which work without Excel.

about BOLD : you have to find out how your OS() Version name it. in German Version it is called "Fett"
gruss by OHR
Jimmy
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

Hi,

to get a Idea what it can do you should read the documentation from here:

http://www.libxl.com/font.html

or look through the methods of the HBLibXL Class ...

there is a function to set bold:

Code: Alles auswählen

bool bold() const
Returns whether the font is bold.
void setBold(bool bold = true)
Turns on/off the bold font.
so add this line to your examle:

oFont1:FontSetBold(.t.)
Gruß
Hubert
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL - SELECTING FONT

Beitrag von brandelh »

AUGE_OHR hat geschrieben: Sa, 02. Dez 2017 3:14
engindenizoglu hat geschrieben: Fr, 01. Dez 2017 20:52 Here below it saves the excel file , but with which function can i open the same excel file ?
-----------------------------------------------------------------------------

Code: Alles auswählen

 oBook:BookSave( cFile )         /*    rec.     */  
 oBook:destroy()
-----------------------------------------------------------------------------
this is for Excel activeX but here we talk about LibXL which work without Excel.
about BOLD : you have to find out how your OS() Version name it. in German Version it is called "Fett"
The code abouve looks like my HBLibXL Class and not ActiveX, so no OS() bold needed ;-)
Gruß
Hubert
Benutzeravatar
engindenizoglu
Cut&Paste-Entwickler
Cut&Paste-Entwickler
Beiträge: 41
Registriert: Mi, 08. Nov 2017 20:58
Wohnort: ISTANBUL

Re: LibXL und Zellen umranden

Beitrag von engindenizoglu »

Bold worked ; Thank u :)


So how can i open an excel file ?

With Activex or LIBXL.
ENGIN RENE D.

LARA ltd
http:\\www.laraelectromechanical.com
Benutzeravatar
brandelh
Foren-Moderator
Foren-Moderator
Beiträge: 15688
Registriert: Mo, 23. Jan 2006 20:54
Wohnort: Germersheim
Hat sich bedankt: 65 Mal
Danksagung erhalten: 33 Mal
Kontaktdaten:

Re: LibXL und Zellen umranden

Beitrag von brandelh »

With ActiveX, there is an example to open a DBF and save it as as XLS in the samples folder of xbase++

:arrow: ..\XPPW32\source\samples\activex\msexcel

in LibXL use the method:

Code: Alles auswählen

Book class reference
public void load(string filename)
Loads an entire file into memory.
:arrow: xlBook:BookLoad( cFilename )
Gruß
Hubert
Antworten