Skip to content

Commit da96975

Browse files
authored
Merge pull request #3 from QtExcel/dev4
update simplexlsx to v0.34
2 parents 81f1e20 + 099465c commit da96975

34 files changed

+2438
-2055
lines changed

QSimpleXlsxWriter/QSimpleXlsxWriter.pri

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SOURCES += \
4343
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Chart.cpp \
4444
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Chartsheet.cpp \
4545
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Drawing.cpp \
46+
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/SimpleXlsxDef.cpp \
4647
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Workbook.cpp \
4748
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Worksheet.cpp \
4849
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/XlsxHeaders.cpp

Samples/DefinedNames.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
3+
#include <Xlsx/Workbook.h>
4+
5+
using namespace SimpleXlsx;
6+
7+
int main()
8+
{
9+
CWorkbook Book( "Incognito" );
10+
CWorksheet & Sheet = Book.AddSheet( "Sheet 1" );
11+
CWorksheet & SecondSheet = Book.AddSheet( "Sheet 2" );
12+
13+
Book.AddDefinedName( "HalfRad", 0.5, "Half radian" ).AddDefinedName( "TestSin", "sin(HalfRad)" );
14+
Book.AddDefinedName( "SingleCell", Sheet, CellCoord( 1, 0 ) );
15+
Book.AddDefinedName( "RangeCells", Sheet, CellCoord( 1, 0 ), CellCoord( 2, 0 ) );
16+
Book.AddDefinedName( "TestScope", Sheet, CellCoord( 1, 0 ), "", & SecondSheet );
17+
18+
Sheet.AddSimpleRow( "=HalfRad" ).AddSimpleRow( "=TestSin" );
19+
Sheet.AddSimpleRow( "=SingleCell" ).AddSimpleRow( "=sum(RangeCells)" );
20+
21+
SecondSheet.AddSimpleRow( "=TestScope" );
22+
23+
if( Book.Save( "DefinedNames.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
24+
else std::cout << "The book saving has been failed" << std::endl;
25+
return 0;
26+
}

Samples/DefinedNames.xlsx

6.26 KB
Binary file not shown.

Samples/Image.jpg

1.51 KB
Loading

Samples/Image.png

1.72 KB
Loading

Samples/Images.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
using namespace SimpleXlsx;
66

7-
int main( int argc, char * argv[] )
7+
int main()
88
{
9-
( void )argc; ( void )argv;
10-
119
setlocale( LC_ALL, "" );
1210

1311
CWorkbook Book( "Incognito" );
@@ -21,7 +19,6 @@ int main( int argc, char * argv[] )
2119
Sheet.AddCell( "Scaled image:" );
2220
Sheet.EndRow();
2321

24-
// TODO: set image path
2522
Book.AddImage( Sheet, "Image.gif", DrawingPoint( 0, 1 ) );
2623
Book.AddImage( Sheet, "Image.jpg", DrawingPoint( 0, 4 ) );
2724
Book.AddImage( Sheet, "Image.png", DrawingPoint( 0, 7 ) );
@@ -33,6 +30,5 @@ int main( int argc, char * argv[] )
3330

3431
if( Book.Save( "Images.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
3532
else std::cout << "The book saving has been failed" << std::endl;
36-
3733
return 0;
3834
}

Samples/Images.xlsx

20.3 KB
Binary file not shown.

Samples/MultiCharts.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1+
#include <cmath>
2+
#include <cstdio>
3+
#include <cstdlib>
4+
#include <ctime>
15
#include <iostream>
2-
#include <math.h>
3-
#include <stdio.h>
4-
#include <stdlib.h>
5-
#include <time.h>
66

77
#include <Xlsx/Chart.h>
88
#include <Xlsx/Chartsheet.h>
99
#include <Xlsx/Workbook.h>
1010

1111
using namespace SimpleXlsx;
1212

13-
int main( int argc, char * argv[] )
13+
int main()
1414
{
15-
( void )argc; ( void )argv;
16-
1715
setlocale( LC_ALL, "" );
1816

1917
time_t CurrentTime = time( NULL );
@@ -38,12 +36,10 @@ int main( int argc, char * argv[] )
3836
data2.push_back( cellDbl );
3937
}
4038

41-
FirstDataSheet.AddRow( data1 ); // data can be added by row or by cell
42-
FirstDataSheet.AddRow( data2 );
39+
FirstDataSheet.AddRow( data1 ).AddRow( data2 ); // data can be added by row or by cell
4340

4441
// adding chart sheet to the workbook the reference to a newly created object is returned
4542
CChartsheet & ChartSheet = Book.AddChartSheet( "Line Chart", CHART_LINEAR );
46-
4743
// create series object, that contains most chart settings
4844
CChart::Series ser;
4945
// leave category sequence (X axis) not specified (optional) - MS Excel will generate the default sequence automatically
@@ -78,14 +74,9 @@ int main( int argc, char * argv[] )
7874
OnSheetChart2.AddSeries( ser2 );
7975
OnSheetChart2.SetLegendPos( CChart::POS_LEFT_ASIDE );
8076

81-
8277
CWorksheet & SecondDataSheet = Book.AddSheet( "Data2" );
8378
for( int i = 0; i < DataCellCount; i++ )
84-
{
85-
SecondDataSheet.BeginRow();
86-
SecondDataSheet.AddCell( sin( i * 0.5 ) + 1 );
87-
SecondDataSheet.EndRow();
88-
}
79+
SecondDataSheet.BeginRow().AddCell( sin( i * 0.5 ) + 1 ).EndRow();
8980

9081
CChart::Series ser3;
9182
ser3.catSheet = NULL;
@@ -101,9 +92,7 @@ int main( int argc, char * argv[] )
10192

10293
Book.SetActiveSheet( ChartSheet );
10394

104-
10595
if( Book.Save( "MultiCharts.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
10696
else std::cout << "The book saving has been failed" << std::endl;
107-
10897
return 0;
10998
}

Samples/MultiCharts.xlsx

14.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)