From 86a79b52cc732c1046cb7bd1deb4d19293160529 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 21 Jul 2012 12:18:17 +0000 Subject: [PATCH] 2012-07-21 14:17 UTC+0200 Viktor Szakats (vszakats syenar.net) * examples/hbxlsxml/tests/example.prg * examples/hbxlsxml/tests/example2.prg * examples/hbxlsxml/tests/example3.prg * examples/hbxlsxml/xlsxml_s.prg ! deleted spaces at EOL --- harbour/ChangeLog | 7 + harbour/examples/hbxlsxml/tests/example.prg | 1 - harbour/examples/hbxlsxml/tests/example2.prg | 30 ++-- harbour/examples/hbxlsxml/tests/example3.prg | 20 +-- harbour/examples/hbxlsxml/xlsxml_s.prg | 175 +++++++++---------- 5 files changed, 119 insertions(+), 114 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5d1bb84dc6..82e93c3a0b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,13 @@ The license applies to all entries newer than 2009-04-28. */ +2012-07-21 14:17 UTC+0200 Viktor Szakats (vszakats syenar.net) + * examples/hbxlsxml/tests/example.prg + * examples/hbxlsxml/tests/example2.prg + * examples/hbxlsxml/tests/example3.prg + * examples/hbxlsxml/xlsxml_s.prg + ! deleted spaces at EOL + 2012-07-21 14:05 UTC+0200 Viktor Szakats (vszakats syenar.net) * contrib/gtwvg/tests/demowvg.prg * contrib/gtwvg/tests/demowvg1.prg diff --git a/harbour/examples/hbxlsxml/tests/example.prg b/harbour/examples/hbxlsxml/tests/example.prg index 6bab90047e..2c3c551dbb 100644 --- a/harbour/examples/hbxlsxml/tests/example.prg +++ b/harbour/examples/hbxlsxml/tests/example.prg @@ -282,4 +282,3 @@ FUNCTION main() RETURN NIL /*----------------------------------------------------------------------*/ - diff --git a/harbour/examples/hbxlsxml/tests/example2.prg b/harbour/examples/hbxlsxml/tests/example2.prg index f52abc9fd1..819f53b1f9 100644 --- a/harbour/examples/hbxlsxml/tests/example2.prg +++ b/harbour/examples/hbxlsxml/tests/example2.prg @@ -9,7 +9,7 @@ * www - http://www.xharbour.org http://harbour-project.org * * Thanks TO Robert F Greer, PHP original version - * http://sourceforge.net/projects/excelwriterxml/ + * http://sourceforge.net/projects/excelwriterxml/ * * This program is free software; you can redistribute it AND/OR modify * it under the terms of the GNU General PUBLIC License as published by @@ -56,9 +56,9 @@ FUNCTION main() LOCAL xml, format1, format2, format3, format4 LOCAL sheet1, sheet2, sheet4 - + xml = ExcelWriterXML():new('my file.xml') - + /** * Add some general properties to the document */ @@ -66,12 +66,12 @@ FUNCTION main() xml:docAuthor('Robert F Greer') xml:docCompany('Greers.Org') xml:docManager('Wife') - + /** * Choose to show any formatting/input errors on a seperate sheet */ //xml:showErrorSheet(.t.) - + /** * Show the style options */ @@ -79,15 +79,15 @@ FUNCTION main() format1:alignRotate(60) format1:alignHorizontal('Left') format1:setFontSize('18') - + format2 = xml:addStyle('verticaltext_left') format2:alignVerticaltext(45) format2:alignHorizontal('Left') - + format3 = xml:addStyle('wraptext_top') format3:alignWraptext() format3:alignVertical('Top') - + /** * Create a new sheet with the XML document */ @@ -101,8 +101,8 @@ FUNCTION main() sheet1:writeString(1,2,'vertical left','verticaltext_left') sheet1:writeString(1,3,'this text has been wrapped and is aligned at the top','wraptext_top') //sheet1:writeString(1,4,'No style applied') - - + + sheet2 = xml:addSheet('Formulas') /** * Wrote three numbers. @@ -123,7 +123,7 @@ FUNCTION main() sheet2:writeString(5,1,'=SUM(R1C2:R3C2)') sheet2:writeFormula('Number',5,2,'=SUM(R1C1:R3C2)') //sheet2:addComment(5,2,'Here is my formula: =SUM(R1C1:R3C2)') - + sheet4 = xml:addSheet('more formatting') format4 = xml:addStyle('my style') format4:setFontBold() @@ -139,14 +139,14 @@ FUNCTION main() sheet4:writeString(2,1,'formatted text + cell color + merged + underlined',format4) // Merge (2,1) with 4 columns to the right and 2 rows down sheet4:cellMerge(2,1,4,2) - + /** * Send the headers, then output the data */ //xml:sendHeaders() xml:writeData('example2.xml') - - RETURN NIL + + RETURN NIL /*----------------------------------------------------------------------*/ - \ No newline at end of file + diff --git a/harbour/examples/hbxlsxml/tests/example3.prg b/harbour/examples/hbxlsxml/tests/example3.prg index 7d6b51b244..8151ece31b 100644 --- a/harbour/examples/hbxlsxml/tests/example3.prg +++ b/harbour/examples/hbxlsxml/tests/example3.prg @@ -9,7 +9,7 @@ * www - http://www.xharbour.org http://harbour-project.org * * Thanks TO Robert F Greer, PHP original version - * http://sourceforge.net/projects/excelwriterxml/ + * http://sourceforge.net/projects/excelwriterxml/ * * This program is free software; you can redistribute it AND/OR modify * it under the terms of the GNU General PUBLIC License as published by @@ -55,31 +55,31 @@ FUNCTION main() LOCAL xml, sheet1, format4 - + xml:= ExcelWriterXML():New('my file.xml') - + sheet1 = xml:addSheet('Plan 1') - + format4 = xml:addStyle('my style') format4:setFontSize(20) format4:setFontColor('yellow') format4:bgColor('blue') - + sheet1:columnWidth(1,150) sheet1:columnWidth(2,150) sheet1:columnWidth(3,150) sheet1:writeString(2,3,'celula 2_3',format4) sheet1:writeString(2,2,'celula 2_2',format4) sheet1:writeString(2,1,'celula 2_1',format4) - + sheet1:writeString(1,1,'celula 1_1',format4) //sheet1:writeString(1,2,'celula 1_2',format4) sheet1:writeString(1,3,'celula 1_3',format4) sheet1:cellMerge(1,1,1,0) - + xml:writeData('example3.xml') - - RETURN NIL + + RETURN NIL /*----------------------------------------------------------------------*/ - \ No newline at end of file + diff --git a/harbour/examples/hbxlsxml/xlsxml_s.prg b/harbour/examples/hbxlsxml/xlsxml_s.prg index bf9c3d1acc..05354bee2d 100644 --- a/harbour/examples/hbxlsxml/xlsxml_s.prg +++ b/harbour/examples/hbxlsxml/xlsxml_s.prg @@ -9,7 +9,7 @@ * www - http://www.xharbour.org http://harbour-project.org * * Thanks TO Robert F Greer, PHP original version - * http://sourceforge.net/projects/excelwriterxml/ + * http://sourceforge.net/projects/excelwriterxml/ * * This program is free software; you can redistribute it AND/OR modify * it under the terms of the GNU General PUBLIC License as published by @@ -57,7 +57,7 @@ /*----------------------------------------------------------------------*/ -CREATE CLASS ExcelWriterXML_Sheet +CREATE CLASS ExcelWriterXML_Sheet DATA id DATA cells INIT {=>} @@ -86,88 +86,88 @@ CREATE CLASS ExcelWriterXML_Sheet METHOD setRowHeight( row, height ) METHOD cellMerge( row,col, width, height ) METHOD addComment( row, col, comment, author ) - + ENDCLASS /*----------------------------------------------------------------------*/ -METHOD ExcelWriterXML_Sheet:new( id ) +METHOD ExcelWriterXML_Sheet:new( id ) + + ::id := id - ::id := id - RETURN SELF - + /*----------------------------------------------------------------------*/ -METHOD ExcelWriterXML_Sheet:getID() +METHOD ExcelWriterXML_Sheet:getID() RETURN ::id - + /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:addError( cFunction, cMessage ) + +METHOD ExcelWriterXML_Sheet:addError( cFunction, cMessage ) LOCAL tmp - + tmp := { 'sheet' => ::id,; 'FUNCTION' => cFunction,; 'MESSAGE' => cMessage } - + ::formatErrors += tmp - + RETURN NIL /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:getErrors() + +METHOD ExcelWriterXML_Sheet:getErrors() RETURN ::formatErrors /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:writeFormula( dataType, row, column, xData, style ) + +METHOD ExcelWriterXML_Sheet:writeFormula( dataType, row, column, xData, style ) HB_SYMBOL_UNUSED( dataType ) - + ::writeData( 'String', row, column, '', style, xData ) - + RETURN NIL /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:writeString( row, column, xData, style ) + +METHOD ExcelWriterXML_Sheet:writeString( row, column, xData, style ) ::writeData( 'String', row, column, xData, style ) - + RETURN NIL - + /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:writeNumber( row, column, xData, style ) + +METHOD ExcelWriterXML_Sheet:writeNumber( row, column, xData, style ) IF !( VALTYPE( xData ) == "N" ) ::writeData( 'String', row, column, xData, style ) ELSE ::writeData( 'Number', row ,column, ALLTRIM( STR( xData, 18, 6 ) ), style ) ENDIF - + RETURN NIL - + /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:writeDateTime( row, column, xData, style ) + +METHOD ExcelWriterXML_Sheet:writeDateTime( row, column, xData, style ) IF VALTYPE( xData ) == "D" ::writeData( 'DateTime', row, column, DTOC( xData ), style ) ELSE ::writeData( 'String', row, column, xData, style ) ENDIF - + RETURN NIL - + /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:writeData( type, row, column, xData, style, formula ) + +METHOD ExcelWriterXML_Sheet:writeData( type, row, column, xData, style, formula ) LOCAL hcol, cell, styleID - + IF style != NIL IF HB_ISOBJECT( style ) styleID := style:getID() @@ -177,7 +177,7 @@ METHOD ExcelWriterXML_Sheet:writeData( type, row, column, xData, style, formula ELSE styleID := NIL ENDIF - + cell := { 'type' => type ,; 'style' => styleID,; 'data' => xData ,; @@ -185,38 +185,38 @@ METHOD ExcelWriterXML_Sheet:writeData( type, row, column, xData, style, formula IF hb_hPos( ::cells, row ) > 0 hcol := ::cells[ row ] hcol[ column ] := cell - ::cells[ row ] := hcol - ELSE + ::cells[ row ] := hcol + ELSE hcol := {=>} hcol[ column ] := cell ::cells[ row ] := hcol ENDIF RETURN NIL - + /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:displayRightToLeft() + +METHOD ExcelWriterXML_Sheet:displayRightToLeft() ::ldisplayRightToLeft := .t. - + RETURN NIL /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) + +METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) LOCAL displayRightToLeft, ir, ic, xml, url - LOCAL column, cell, xData, type, mergecell, comment, style, colIndex, colWidth + LOCAL column, cell, xData, type, mergecell, comment, style, colIndex, colWidth LOCAL row, rowData, rowHeight, formula - + displayRightToLeft := IIF( ::ldisplayRightToLeft, 'ss:RightToLeft="1"', "" ) - + xml := '' + HB_OsNewLine() xml += ' ' + HB_OsNewLine() - + fwrite( handle,xml ) xml := "" - + IF len( ::colWidth ) > 0 FOR ic := 1 TO LEN( ::colWidth ) colIndex := hb_hKeyAt( ::colWidth, ic ) @@ -226,33 +226,33 @@ METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) xml += ' ' + HB_OsNewLine() NEXT ENDIF - + fwrite( handle, xml ) xml := "" - + IF len( ::cells ) > 0 FOR ir := 1 TO LEN( ::cells ) row := hb_hKeyAt( ::cells, ir ) rowData := hb_HValueAt( ::cells, ir ) - + IF hb_hPos( ::rowHeight, row ) > 0 rowHeight := 'ss:AutoFitHeight="0" ss:Height="' + ALLTRIM( STR( ::rowHeight[ row ], 14, 2 ) ) + '"' ELSE rowHeight := '' - ENDIF - + ENDIF + xml += ' ' + HB_OsNewLine() FOR ic := 1 TO LEN( rowData ) column := hb_hKeyAt( rowData, ic ) cell := hb_HValueAt( rowData, ic ) - IF !empty( cell[ 'formula' ] ) + IF !empty( cell[ 'formula' ] ) formula := 'ss:Formula="' + cell['formula'] + '"' - ELSE + ELSE formula := '' ENDIF - IF !empty( cell[ 'style' ] ) + IF !empty( cell[ 'style' ] ) style := 'ss:StyleID="' + cell[ 'style' ] + '"' - ELSE + ELSE style := '' ENDIF URL := '' @@ -276,104 +276,103 @@ METHOD ExcelWriterXML_Sheet:getSheetXML( handle ) comment := '' type := cell[ 'type' ] xData := cell[ 'data' ] - + xml += ' ' + HB_OsNewLine() xml += ' ' xml += oemToHtmlEspecial( xData ) xml += '' + HB_OsNewLine() xml += comment xml += ' ' + HB_OsNewLine() - + NEXT xml += ' ' + HB_OsNewLine() - + fwrite( handle, xml ) xml := "" NEXT ENDIF xml += '
'+HB_OsNewLine() xml += '
'+HB_OsNewLine() - + fwrite( handle, xml ) xml := "" - + RETURN xml - + /*----------------------------------------------------------------------*/ -METHOD ExcelWriterXML_Sheet:cellWidth( row, col, width ) +METHOD ExcelWriterXML_Sheet:cellWidth( row, col, width ) HB_SYMBOL_UNUSED( row ) HB_SYMBOL_UNUSED( col ) - + IF width == NIL width := 48 ENDIF ::columnWidth( col,width ) - + RETURN NIL /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:columnWidth( col, width ) + +METHOD ExcelWriterXML_Sheet:columnWidth( col, width ) IF width == NIL width := 48 ENDIF ::colWidth[ col ] := width - + RETURN NIL /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:cellHeight( row, col, height ) + +METHOD ExcelWriterXML_Sheet:cellHeight( row, col, height ) HB_SYMBOL_UNUSED( col ) - + IF height == NIL height := 12.5 ENDIF ::setRowHeight( row, height ) - + RETURN NIL /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:setRowHeight( row, height ) + +METHOD ExcelWriterXML_Sheet:setRowHeight( row, height ) IF height == NIL height := 12.5 ENDIF ::rowHeight[ row ] := height - + RETURN NIL /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:cellMerge( row,col, width, height ) + +METHOD ExcelWriterXML_Sheet:cellMerge( row,col, width, height ) LOCAL haux := {=>} - + IF hb_hPos( ::mergeCells, row ) > 0 haux := ::mergeCells[ row ] ENDIF haux[ col ] := { 'width' => width, ; 'height' => height } - + ::mergeCells[ row ] := haux - + RETURN NIL - + /*----------------------------------------------------------------------*/ - -METHOD ExcelWriterXML_Sheet:addComment( row, col,comment,author ) + +METHOD ExcelWriterXML_Sheet:addComment( row, col,comment,author ) LOCAL haux := {=>} - + haux[ col ] := { 'comment' => comment,; 'author' => author } ::comments[ row ]:= haux - + RETURN NIL /*----------------------------------------------------------------------*/ -