Skip to content

Commit

Permalink
Merge pull request #3 from QtExcel/dev4
Browse files Browse the repository at this point in the history
update simplexlsx to v0.34
  • Loading branch information
j2doll authored Feb 8, 2020
2 parents 81f1e20 + 099465c commit da96975
Show file tree
Hide file tree
Showing 34 changed files with 2,438 additions and 2,055 deletions.
1 change: 1 addition & 0 deletions QSimpleXlsxWriter/QSimpleXlsxWriter.pri
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ SOURCES += \
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Chart.cpp \
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Chartsheet.cpp \
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Drawing.cpp \
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/SimpleXlsxDef.cpp \
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Workbook.cpp \
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/Worksheet.cpp \
$${SIMPLE_XLSX_WRITER_PARENTPATH}Xlsx/XlsxHeaders.cpp
Expand Down
26 changes: 26 additions & 0 deletions Samples/DefinedNames.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>

#include <Xlsx/Workbook.h>

using namespace SimpleXlsx;

int main()
{
CWorkbook Book( "Incognito" );
CWorksheet & Sheet = Book.AddSheet( "Sheet 1" );
CWorksheet & SecondSheet = Book.AddSheet( "Sheet 2" );

Book.AddDefinedName( "HalfRad", 0.5, "Half radian" ).AddDefinedName( "TestSin", "sin(HalfRad)" );
Book.AddDefinedName( "SingleCell", Sheet, CellCoord( 1, 0 ) );
Book.AddDefinedName( "RangeCells", Sheet, CellCoord( 1, 0 ), CellCoord( 2, 0 ) );
Book.AddDefinedName( "TestScope", Sheet, CellCoord( 1, 0 ), "", & SecondSheet );

Sheet.AddSimpleRow( "=HalfRad" ).AddSimpleRow( "=TestSin" );
Sheet.AddSimpleRow( "=SingleCell" ).AddSimpleRow( "=sum(RangeCells)" );

SecondSheet.AddSimpleRow( "=TestScope" );

if( Book.Save( "DefinedNames.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
else std::cout << "The book saving has been failed" << std::endl;
return 0;
}
Binary file added Samples/DefinedNames.xlsx
Binary file not shown.
Binary file modified Samples/Image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Samples/Image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions Samples/Images.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

using namespace SimpleXlsx;

int main( int argc, char * argv[] )
int main()
{
( void )argc; ( void )argv;

setlocale( LC_ALL, "" );

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

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

if( Book.Save( "Images.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
else std::cout << "The book saving has been failed" << std::endl;

return 0;
}
Binary file added Samples/Images.xlsx
Binary file not shown.
25 changes: 7 additions & 18 deletions Samples/MultiCharts.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <Xlsx/Chart.h>
#include <Xlsx/Chartsheet.h>
#include <Xlsx/Workbook.h>

using namespace SimpleXlsx;

int main( int argc, char * argv[] )
int main()
{
( void )argc; ( void )argv;

setlocale( LC_ALL, "" );

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

FirstDataSheet.AddRow( data1 ); // data can be added by row or by cell
FirstDataSheet.AddRow( data2 );
FirstDataSheet.AddRow( data1 ).AddRow( data2 ); // data can be added by row or by cell

// adding chart sheet to the workbook the reference to a newly created object is returned
CChartsheet & ChartSheet = Book.AddChartSheet( "Line Chart", CHART_LINEAR );

// create series object, that contains most chart settings
CChart::Series ser;
// leave category sequence (X axis) not specified (optional) - MS Excel will generate the default sequence automatically
Expand Down Expand Up @@ -78,14 +74,9 @@ int main( int argc, char * argv[] )
OnSheetChart2.AddSeries( ser2 );
OnSheetChart2.SetLegendPos( CChart::POS_LEFT_ASIDE );


CWorksheet & SecondDataSheet = Book.AddSheet( "Data2" );
for( int i = 0; i < DataCellCount; i++ )
{
SecondDataSheet.BeginRow();
SecondDataSheet.AddCell( sin( i * 0.5 ) + 1 );
SecondDataSheet.EndRow();
}
SecondDataSheet.BeginRow().AddCell( sin( i * 0.5 ) + 1 ).EndRow();

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

Book.SetActiveSheet( ChartSheet );


if( Book.Save( "MultiCharts.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
else std::cout << "The book saving has been failed" << std::endl;

return 0;
}
Binary file added Samples/MultiCharts.xlsx
Binary file not shown.
Loading

0 comments on commit da96975

Please sign in to comment.