From 133dbea920797f5a21787bb5322c0eff1abc7b3b Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Fri, 28 Apr 2017 11:41:22 +1000 Subject: [PATCH 01/17] Adding Ubuntu installation instructions Working on the baseline environment set up and the installation of the compiler (from source), more to come --- docs/introduction/Installation.md | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index 106206c0..51d909fc 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -8,6 +8,49 @@ ## vcpkg +## Compiling from Source - Ubuntu 16.04 LTS (Xenial Xerus) +Please run the following commands and read the comments as you go. +You will notice that we update and upgrade quite frequently, this is to ensure that all dependancies are met at all times +``` +sudo apt-get update +sudo apt-get upgrade +sudo apt-get install cmake +sudo apt-get install zlibc +sudo apt-get install zlib1g +sudo apt-get install zlib1g-dev +sudo apt-get install libssl-dev +sudo add-apt-repository ppa:ubuntu-toolchain-r/test +sudo apt update +sudo apt-get upgrade +sudo apt-get install gcc-6 g++-6 +sudo apt update +sudo apt-get upgrade +``` +The following steps will set up some environment variables for this session +``` +export CC=/usr/bin/gcc-6 and +export CXX=/usr/bin/g++-6 +``` +The following steps will install the latest compiler from source +Download gcc 6.3.0 from https://gcc.gnu.org/mirrors.html I used the Japanese mirror as this is the closest location to me http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.gz + +``` +cd ~ +tar -zxvf Downloads/gcc-6.3.0.tar.gz +cd gcc-6.3.0 +./contrib/download_prerequisites +mkdir build +cd build +../configure --disable-multilib --enable-languages=c,c++ +make -j 2 +``` +If the above fails please use the following command to clean up and prepare the environment for another attempt +``` +make clean pristine +``` + + + ## Compiling from Source Build configurations for Visual Studio, GNU Make, Ninja, and Xcode can be created using [cmake](https://cmake.org/) v3.2+. A full list of cmake generators can be found [here](https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html). A basic build would look like (starting in the root xlnt directory): From 1214c4d2ce0160edc5b56c48437b7f3f87f51a23 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Fri, 28 Apr 2017 13:43:33 +1000 Subject: [PATCH 02/17] Updating the TODO section Adding the future steps in readiness; waiting for the gcc 6.3.0 to compile - boy that takes a while. Next step is to run everything after the TODO line and the create a pull request to finalize the documentation --- docs/introduction/Installation.md | 45 ++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index 51d909fc..6a4a6caf 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -31,6 +31,15 @@ The following steps will set up some environment variables for this session export CC=/usr/bin/gcc-6 and export CXX=/usr/bin/g++-6 ``` +The following steps will install the appropriate crypto libraries for c++ +Download the zip file from https://github.com/weidai11/cryptopp/archive/master.zip +``` +cd ~ +unzip Downloads/cryptopp-master.zip +cd cryptopp-master +make +sudo make install +``` The following steps will install the latest compiler from source Download gcc 6.3.0 from https://gcc.gnu.org/mirrors.html I used the Japanese mirror as this is the closest location to me http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.gz @@ -43,13 +52,43 @@ mkdir build cd build ../configure --disable-multilib --enable-languages=c,c++ make -j 2 +sudo make install ``` -If the above fails please use the following command to clean up and prepare the environment for another attempt +If the above make command fails please use the following command to clean up and prepare the environment for another attempt. A common reason for failure on virtual machines is lack of RAM (if you don't have enough RAM you may get an error like this "recipe for target 's-attrtab' failed"). ``` make clean pristine ``` - - +#TODO +The following step will install the docbook2x library +``` +sudo apt-get install docbook2x +``` +The following steps will install the libexpat library +Download the zip file from the following repository https://github.com/libexpat/libexpat +``` +cd ~ +unzip Downloads/libexpat.zip +cd libexpat +cmake +sudo make install +``` +The following step will map the shared library names to the location of the corresponding shared library files +``` +sudo ldconfig +``` +The following steps will intall xlnt +Download the zip file from the xlnt repository +https://github.com/tfussell/xlnt/archive/master.zip +``` +cd ~ +unzip Downloads/master.zip +cd xlnt +mkdir build +cd build +cmake +make -j 2 +sudo make install +``` ## Compiling from Source From 5268651937678b6efb56df95197eb6ef9b37e865 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Fri, 28 Apr 2017 13:46:19 +1000 Subject: [PATCH 03/17] Updating the comments Still waiting for gcc to compile --- docs/introduction/Installation.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index 6a4a6caf..a684baab 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -54,10 +54,8 @@ cd build make -j 2 sudo make install ``` -If the above make command fails please use the following command to clean up and prepare the environment for another attempt. A common reason for failure on virtual machines is lack of RAM (if you don't have enough RAM you may get an error like this "recipe for target 's-attrtab' failed"). -``` -make clean pristine -``` +If the above make command fails please use "make clean pristine" and then remove and remake the build directory. This will clean up and prepare the environment for another attempt. A common reason for failure on virtual machines is lack of RAM (if you don't have enough RAM you may get an error like this "recipe for target 's-attrtab' failed"). Otherwise, if all goes well in about 30 to 60 minutes the compiler will be ready and we will move on to the next steps. + #TODO The following step will install the docbook2x library ``` From 3ce51089cd27c76b82e7a320b3bf85a31f8847c7 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Sun, 30 Apr 2017 19:13:59 +1000 Subject: [PATCH 04/17] Finished installing xlnt Need to test some code now --- docs/introduction/Installation.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index a684baab..25b914af 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -28,7 +28,7 @@ sudo apt-get upgrade ``` The following steps will set up some environment variables for this session ``` -export CC=/usr/bin/gcc-6 and +export CC=/usr/bin/gcc-6 export CXX=/usr/bin/g++-6 ``` The following steps will install the appropriate crypto libraries for c++ @@ -56,18 +56,20 @@ sudo make install ``` If the above make command fails please use "make clean pristine" and then remove and remake the build directory. This will clean up and prepare the environment for another attempt. A common reason for failure on virtual machines is lack of RAM (if you don't have enough RAM you may get an error like this "recipe for target 's-attrtab' failed"). Otherwise, if all goes well in about 30 to 60 minutes the compiler will be ready and we will move on to the next steps. -#TODO The following step will install the docbook2x library ``` sudo apt-get install docbook2x ``` + +#TODO The following steps will install the libexpat library Download the zip file from the following repository https://github.com/libexpat/libexpat ``` cd ~ unzip Downloads/libexpat.zip -cd libexpat -cmake +cd libexpat-master/expat +cmake . +make sudo make install ``` The following step will map the shared library names to the location of the corresponding shared library files @@ -79,11 +81,9 @@ Download the zip file from the xlnt repository https://github.com/tfussell/xlnt/archive/master.zip ``` cd ~ -unzip Downloads/master.zip -cd xlnt -mkdir build -cd build -cmake +unzip Downloads/xlnt-master.zip +cd xlnt-master +cmake . make -j 2 sudo make install ``` From 0a6d0930102c6dca55997e643b25871dfc07e8a6 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Mon, 1 May 2017 07:49:59 +1000 Subject: [PATCH 05/17] Finalizing Ubuntu installation documentation Ready for pull request --- docs/introduction/Installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index 25b914af..aaa0e777 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -37,7 +37,7 @@ Download the zip file from https://github.com/weidai11/cryptopp/archive/master.z cd ~ unzip Downloads/cryptopp-master.zip cd cryptopp-master -make +make -j 2 sudo make install ``` The following steps will install the latest compiler from source @@ -66,10 +66,10 @@ The following steps will install the libexpat library Download the zip file from the following repository https://github.com/libexpat/libexpat ``` cd ~ -unzip Downloads/libexpat.zip +unzip Downloads/libexpat-master.zip cd libexpat-master/expat cmake . -make +make -j 2 sudo make install ``` The following step will map the shared library names to the location of the corresponding shared library files From 30914a930f9dc6c83c6104637342e2834315636e Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Mon, 1 May 2017 07:52:02 +1000 Subject: [PATCH 06/17] Fixing up some formatting Removing the TODO from last commit --- docs/introduction/Installation.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index aaa0e777..637b59fb 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -60,8 +60,6 @@ The following step will install the docbook2x library ``` sudo apt-get install docbook2x ``` - -#TODO The following steps will install the libexpat library Download the zip file from the following repository https://github.com/libexpat/libexpat ``` @@ -87,6 +85,7 @@ cmake . make -j 2 sudo make install ``` +xlnt will now be ready to use on your Ubuntu instance. ## Compiling from Source From 292c7faea4a339b69c3dfaeedbc6b7bd8d3e22ca Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Mon, 1 May 2017 08:53:53 +1000 Subject: [PATCH 07/17] Adding ldconfig command at the end of Ubunbtu doc Need to run ldconf so that the shared libraries are found when running cpp executable (your xlnt program) --- docs/introduction/Installation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index 637b59fb..03754718 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -70,10 +70,6 @@ cmake . make -j 2 sudo make install ``` -The following step will map the shared library names to the location of the corresponding shared library files -``` -sudo ldconfig -``` The following steps will intall xlnt Download the zip file from the xlnt repository https://github.com/tfussell/xlnt/archive/master.zip @@ -85,6 +81,10 @@ cmake . make -j 2 sudo make install ``` +The following step will map the shared library names to the location of the corresponding shared library files +``` +sudo ldconfig +``` xlnt will now be ready to use on your Ubuntu instance. ## Compiling from Source From f3e475d4aef3ca6b305c4a5bc79bb76b58e0ea46 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Mon, 1 May 2017 09:45:41 +1000 Subject: [PATCH 08/17] Adding a simple read example A simple writing example to come soon. More complex examples also coming soon and hopefully high performance examples will not be too far away. --- docs/introduction/Examples.md | 55 ++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index acfebc0e..afeb8d8e 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -1 +1,54 @@ -## Examples \ No newline at end of file +## Examples +### Simple - reading from an existing xlsx spread sheet. +The following C plus plus code will read the values from an xlsx file and print the string values to the screen. This is a very simple example to get you started. + +``` +#include +#include + +using namespace std; +using namespace xlnt; + +int main() +{ + workbook wb; + wb.load("/home/timothymccallum/test.xlsx"); + auto ws = wb.active_sheet(); + clog << "Processing spread sheet" << endl; + for (auto row : ws.rows(false)) + { + for (auto cell : row) + { + clog << cell.to_string() << endl; + } + } + clog << "Processing complete" << endl; + return 0; +} +``` +Save the contents of the above file +``` +/home/timothymccallum/process.cpp +``` +Compile by typing the following command +``` +g++ -std=c++14 -Ixlnt/include -Lxlnt/lib -lxlnt process.cpp -o process +``` +Excecute by typing the following command +``` +./process +``` +The output of the program, in my case, is as follows +``` +Processing spread sheet +This is cell A1. +This is cell B1 +… and this is cell C1 +We are now on the second row at cell A2 +B2 +C2 +Processing complete +``` +As you can see the process.cpp file simply walks through the spread sheet values row by row and column by column (A1, B1, C1, A2, B2, C2 and so on). + +### Simple - writing values to a new xlsx spread sheet. From e1224944957e7659d0f527fa26595d955f66219f Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Mon, 1 May 2017 09:46:18 +1000 Subject: [PATCH 09/17] Update Installation.md --- docs/introduction/Installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index 03754718..1cec2f0c 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -10,7 +10,7 @@ ## Compiling from Source - Ubuntu 16.04 LTS (Xenial Xerus) Please run the following commands and read the comments as you go. -You will notice that we update and upgrade quite frequently, this is to ensure that all dependancies are met at all times +You will notice that we update and upgrade quite frequently, this is to ensure that all dependancies are met at all times. You will also notice that we are installing some libraries from source, there are two reasons for this; firstly in the event that the library is not available through apt-get or secondly, because we want the very latest version (not the version available in apt-get). ``` sudo apt-get update sudo apt-get upgrade @@ -40,7 +40,7 @@ cd cryptopp-master make -j 2 sudo make install ``` -The following steps will install the latest compiler from source +The following steps will install the latest GCC compiler from source (you will notice that we installed GCC 6 using apt-get, this was a building block to the next step of getting GCC 6.3.0 - the latest compiler available at present). Download gcc 6.3.0 from https://gcc.gnu.org/mirrors.html I used the Japanese mirror as this is the closest location to me http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.gz ``` From 356c851dfdfa66f9cefa519ab348e9b2a7e2d130 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Tue, 2 May 2017 21:32:16 +1000 Subject: [PATCH 10/17] Fixing up formatting Fixing indent --- docs/introduction/Examples.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index afeb8d8e..35faf343 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -11,8 +11,8 @@ using namespace xlnt; int main() { - workbook wb; - wb.load("/home/timothymccallum/test.xlsx"); + workbook wb; + wb.load("/home/timothymccallum/test.xlsx"); auto ws = wb.active_sheet(); clog << "Processing spread sheet" << endl; for (auto row : ws.rows(false)) From 7298bc0d9db54d10606f6466843cdd36843ed7b6 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Tue, 2 May 2017 21:34:25 +1000 Subject: [PATCH 11/17] Fixing indenting --- docs/introduction/Examples.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index 35faf343..dd22ae5c 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -8,22 +8,21 @@ The following C plus plus code will read the values from an xlsx file and print using namespace std; using namespace xlnt; - int main() { workbook wb; wb.load("/home/timothymccallum/test.xlsx"); auto ws = wb.active_sheet(); clog << "Processing spread sheet" << endl; - for (auto row : ws.rows(false)) - { - for (auto cell : row) - { - clog << cell.to_string() << endl; - } + for (auto row : ws.rows(false)) + { + for (auto cell : row) + { + clog << cell.to_string() << endl; } - clog << "Processing complete" << endl; - return 0; + } + clog << "Processing complete" << endl; + return 0; } ``` Save the contents of the above file From ed900e28dcb9e6a04537a7e7dbdcf1b5a90aba9a Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Tue, 2 May 2017 22:03:17 +1000 Subject: [PATCH 12/17] Providing example of how to data into C++ Vector Just an example of how to read a spread sheet into memory. Also a little word on performance. More to come on this later. --- docs/introduction/Examples.md | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index dd22ae5c..ece34bb7 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -50,4 +50,89 @@ Processing complete ``` As you can see the process.cpp file simply walks through the spread sheet values row by row and column by column (A1, B1, C1, A2, B2, C2 and so on). +### Simple - storing a spread sheet in a 2 dimensional C++ Vector for further processing +Loading a spread sheet into a Vector provides oppourtunities for you to perform high performance processing. There will be more examples on performing fast look-ups, merging data, performing deduplication and more. For now, let's just learn how to get the spread sheet loaded into memory. +``` +#include +#include +#include + +using namespace std; +using namespace xlnt; + + +int main() +{ + workbook wb; + wb.load("/home/timothymccallum/test.xlsx"); + auto ws = wb.active_sheet(); + clog << "Processing spread sheet" << endl; + clog << "Creating a single vector which stores the whole spread sheet" << endl; + vector< vector > theWholeSpreadSheet; + for (auto row : ws.rows(false)) + { + clog << "Creating a fresh vector for just this row in the spread sheet" << endl; + vector aSingleRow; + for (auto cell : row) + { + clog << "Adding this cell to the row" << endl; + aSingleRow.push_back(cell.to_string()); + } + clog << "Adding this entire row to the vector which stores the whole spread sheet" << endl; + theWholeSpreadSheet.push_back(aSingleRow); + } + clog << "Processing complete" << endl; + + clog << "Reading the vector and printing output to the screen" << endl; + for (int rowInt = 0; rowInt < theWholeSpreadSheet.size(); rowInt++) + { + for (int colInt = 0; colInt < theWholeSpreadSheet.at(rowInt).size(); colInt++) + { + cout << theWholeSpreadSheet.at(rowInt).at(colInt) << endl; + } + } + return 0; +} +``` +Save the contents of the above file +``` +/home/timothymccallum/process.cpp +``` +Compile by typing the following command +``` +g++ -std=c++14 -Ixlnt/include -Lxlnt/lib -lxlnt process.cpp -o process +``` +Excecute by typing the following command +``` +./process +``` +The output of the program, in my case, is as follows +``` +Processing spread sheet +Creating a single vector which stores the whole spread sheet +Creating a fresh vector for just this row in the spread sheet +Adding this cell to the row +Adding this cell to the row +Adding this cell to the row +Adding this entire row to the vector which stores the whole spread sheet +Creating a fresh vector for just this row in the spread sheet +Adding this cell to the row +Adding this cell to the row +Adding this cell to the row +Adding this entire row to the vector which stores the whole spread sheet +Processing complete +Reading the vector and printing output to the screen +This is cell A1. +This is cell B1 +… and this is cell C1 +We are now on the second row at cell A2 +B2 +C2 +``` +You will have noticed that this process is very fast. If you type the "time" as shown below, you can measure just how fast loading and retrieving your spread sheet is, using xlnt; In this case only a fraction of a second. More on this later. +``` +time ./process +... +real 0m0.044s +``` ### Simple - writing values to a new xlsx spread sheet. From 0dcdb01bf6d06dcfacf2841f6c930137ff18cf11 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Tue, 2 May 2017 22:06:47 +1000 Subject: [PATCH 13/17] Fixing indent Just formatting --- docs/introduction/Examples.md | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index ece34bb7..1aeee8b4 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -70,28 +70,27 @@ int main() clog << "Creating a single vector which stores the whole spread sheet" << endl; vector< vector > theWholeSpreadSheet; for (auto row : ws.rows(false)) - { - clog << "Creating a fresh vector for just this row in the spread sheet" << endl; - vector aSingleRow; - for (auto cell : row) - { - clog << "Adding this cell to the row" << endl; - aSingleRow.push_back(cell.to_string()); - } - clog << "Adding this entire row to the vector which stores the whole spread sheet" << endl; - theWholeSpreadSheet.push_back(aSingleRow); - } - clog << "Processing complete" << endl; - - clog << "Reading the vector and printing output to the screen" << endl; - for (int rowInt = 0; rowInt < theWholeSpreadSheet.size(); rowInt++) + { + clog << "Creating a fresh vector for just this row in the spread sheet" << endl; + vector aSingleRow; + for (auto cell : row) + { + clog << "Adding this cell to the row" << endl; + aSingleRow.push_back(cell.to_string()); + } + clog << "Adding this entire row to the vector which stores the whole spread sheet" << endl; + theWholeSpreadSheet.push_back(aSingleRow); + } + clog << "Processing complete" << endl; + clog << "Reading the vector and printing output to the screen" << endl; + for (int rowInt = 0; rowInt < theWholeSpreadSheet.size(); rowInt++) { - for (int colInt = 0; colInt < theWholeSpreadSheet.at(rowInt).size(); colInt++) + for (int colInt = 0; colInt < theWholeSpreadSheet.at(rowInt).size(); colInt++) { - cout << theWholeSpreadSheet.at(rowInt).at(colInt) << endl; + cout << theWholeSpreadSheet.at(rowInt).at(colInt) << endl; } } - return 0; + return 0; } ``` Save the contents of the above file From 4c5e5f3b2cb21beed1361666e7bf721f4143ec57 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Thu, 4 May 2017 08:24:03 +1000 Subject: [PATCH 14/17] Changing indent level of braces Using Allman indent style --- docs/introduction/Examples.md | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index 1aeee8b4..07789a99 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -15,12 +15,12 @@ int main() auto ws = wb.active_sheet(); clog << "Processing spread sheet" << endl; for (auto row : ws.rows(false)) + { + for (auto cell : row) { - for (auto cell : row) - { - clog << cell.to_string() << endl; - } + clog << cell.to_string() << endl; } + } clog << "Processing complete" << endl; return 0; } @@ -69,27 +69,27 @@ int main() clog << "Processing spread sheet" << endl; clog << "Creating a single vector which stores the whole spread sheet" << endl; vector< vector > theWholeSpreadSheet; - for (auto row : ws.rows(false)) - { - clog << "Creating a fresh vector for just this row in the spread sheet" << endl; - vector aSingleRow; - for (auto cell : row) - { - clog << "Adding this cell to the row" << endl; - aSingleRow.push_back(cell.to_string()); - } - clog << "Adding this entire row to the vector which stores the whole spread sheet" << endl; - theWholeSpreadSheet.push_back(aSingleRow); - } + for (auto row : ws.rows(false)) + { + clog << "Creating a fresh vector for just this row in the spread sheet" << endl; + vector aSingleRow; + for (auto cell : row) + { + clog << "Adding this cell to the row" << endl; + aSingleRow.push_back(cell.to_string()); + } + clog << "Adding this entire row to the vector which stores the whole spread sheet" << endl; + theWholeSpreadSheet.push_back(aSingleRow); + } clog << "Processing complete" << endl; clog << "Reading the vector and printing output to the screen" << endl; for (int rowInt = 0; rowInt < theWholeSpreadSheet.size(); rowInt++) + { + for (int colInt = 0; colInt < theWholeSpreadSheet.at(rowInt).size(); colInt++) { - for (int colInt = 0; colInt < theWholeSpreadSheet.at(rowInt).size(); colInt++) - { - cout << theWholeSpreadSheet.at(rowInt).at(colInt) << endl; - } - } + cout << theWholeSpreadSheet.at(rowInt).at(colInt) << endl; + } + } return 0; } ``` From b5997bd878cb77b8fa8f36bdb7da92bf8ef1e5c4 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Thu, 4 May 2017 08:31:35 +1000 Subject: [PATCH 15/17] Updating compile command Removing the -I and -L arguments from the compile command. I realize that it is unnecessary to specify a list of directories (to be searched) for header files and so forth in the event that the standard xlnt installation process was followed. --- docs/introduction/Examples.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index 07789a99..153023df 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -31,7 +31,7 @@ Save the contents of the above file ``` Compile by typing the following command ``` -g++ -std=c++14 -Ixlnt/include -Lxlnt/lib -lxlnt process.cpp -o process +g++ -std=c++14 -lxlnt process.cpp -o process ``` Excecute by typing the following command ``` @@ -99,7 +99,7 @@ Save the contents of the above file ``` Compile by typing the following command ``` -g++ -std=c++14 -Ixlnt/include -Lxlnt/lib -lxlnt process.cpp -o process +g++ -std=c++14 -lxlnt process.cpp -o process ``` Excecute by typing the following command ``` From c430fca9fff6eb840bc92702b385d8e27ef29388 Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Thu, 4 May 2017 08:48:08 +1000 Subject: [PATCH 16/17] Removing the third-party runtime dependencies Removing zlib1g, libssl-dev, cryptopp, and expat. Cryptography now uses public domain code in the source tree (source/detail/cryptography), zlib was replaced with miniz and added to the source tree (source/detail/serialization/miniz.*), and since it's already a part of libstudxml (i.e. a grandchild dependency), xlnt is now using libstudxml's expat (third-party/libstudxml/xml/details/expat). --- docs/introduction/Installation.md | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/docs/introduction/Installation.md b/docs/introduction/Installation.md index 1cec2f0c..cfefe11d 100644 --- a/docs/introduction/Installation.md +++ b/docs/introduction/Installation.md @@ -16,9 +16,6 @@ sudo apt-get update sudo apt-get upgrade sudo apt-get install cmake sudo apt-get install zlibc -sudo apt-get install zlib1g -sudo apt-get install zlib1g-dev -sudo apt-get install libssl-dev sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt-get upgrade @@ -31,15 +28,6 @@ The following steps will set up some environment variables for this session export CC=/usr/bin/gcc-6 export CXX=/usr/bin/g++-6 ``` -The following steps will install the appropriate crypto libraries for c++ -Download the zip file from https://github.com/weidai11/cryptopp/archive/master.zip -``` -cd ~ -unzip Downloads/cryptopp-master.zip -cd cryptopp-master -make -j 2 -sudo make install -``` The following steps will install the latest GCC compiler from source (you will notice that we installed GCC 6 using apt-get, this was a building block to the next step of getting GCC 6.3.0 - the latest compiler available at present). Download gcc 6.3.0 from https://gcc.gnu.org/mirrors.html I used the Japanese mirror as this is the closest location to me http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.gz @@ -56,20 +44,6 @@ sudo make install ``` If the above make command fails please use "make clean pristine" and then remove and remake the build directory. This will clean up and prepare the environment for another attempt. A common reason for failure on virtual machines is lack of RAM (if you don't have enough RAM you may get an error like this "recipe for target 's-attrtab' failed"). Otherwise, if all goes well in about 30 to 60 minutes the compiler will be ready and we will move on to the next steps. -The following step will install the docbook2x library -``` -sudo apt-get install docbook2x -``` -The following steps will install the libexpat library -Download the zip file from the following repository https://github.com/libexpat/libexpat -``` -cd ~ -unzip Downloads/libexpat-master.zip -cd libexpat-master/expat -cmake . -make -j 2 -sudo make install -``` The following steps will intall xlnt Download the zip file from the xlnt repository https://github.com/tfussell/xlnt/archive/master.zip From 32dba9570945bb0c37875b5224dbf02b6b007afc Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Thu, 4 May 2017 09:15:18 +1000 Subject: [PATCH 17/17] Removing using namespace in the header This has been updated and is ready for deployment. No namespaces used in the header of the code now, just explicit calls in the functions. std::string, std::vector, std::clog, std::endl, xlnt::workbook. --- docs/introduction/Examples.md | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index 153023df..9185b5eb 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -6,22 +6,20 @@ The following C plus plus code will read the values from an xlsx file and print #include #include -using namespace std; -using namespace xlnt; int main() { - workbook wb; + xlnt::workbook wb; wb.load("/home/timothymccallum/test.xlsx"); auto ws = wb.active_sheet(); - clog << "Processing spread sheet" << endl; + std::clog << "Processing spread sheet" << std::endl; for (auto row : ws.rows(false)) { for (auto cell : row) { - clog << cell.to_string() << endl; + std::clog << cell.to_string() << std::endl; } } - clog << "Processing complete" << endl; + std::clog << "Processing complete" << std::endl; return 0; } ``` @@ -57,37 +55,33 @@ Loading a spread sheet into a Vector provides oppourtunities for you to perform #include #include -using namespace std; -using namespace xlnt; - - int main() { - workbook wb; + xlnt::workbook wb; wb.load("/home/timothymccallum/test.xlsx"); auto ws = wb.active_sheet(); - clog << "Processing spread sheet" << endl; - clog << "Creating a single vector which stores the whole spread sheet" << endl; - vector< vector > theWholeSpreadSheet; + std::clog << "Processing spread sheet" << std::endl; + std::clog << "Creating a single vector which stores the whole spread sheet" << std::endl; + std::vector< std::vector > theWholeSpreadSheet; for (auto row : ws.rows(false)) { - clog << "Creating a fresh vector for just this row in the spread sheet" << endl; - vector aSingleRow; + std::clog << "Creating a fresh vector for just this row in the spread sheet" << std::endl; + std::vector aSingleRow; for (auto cell : row) { - clog << "Adding this cell to the row" << endl; + std::clog << "Adding this cell to the row" << std::endl; aSingleRow.push_back(cell.to_string()); } - clog << "Adding this entire row to the vector which stores the whole spread sheet" << endl; + std::clog << "Adding this entire row to the vector which stores the whole spread sheet" << std::endl; theWholeSpreadSheet.push_back(aSingleRow); } - clog << "Processing complete" << endl; - clog << "Reading the vector and printing output to the screen" << endl; + std::clog << "Processing complete" << std::endl; + std::clog << "Reading the vector and printing output to the screen" << std::endl; for (int rowInt = 0; rowInt < theWholeSpreadSheet.size(); rowInt++) { for (int colInt = 0; colInt < theWholeSpreadSheet.at(rowInt).size(); colInt++) { - cout << theWholeSpreadSheet.at(rowInt).at(colInt) << endl; + std::cout << theWholeSpreadSheet.at(rowInt).at(colInt) << std::endl; } } return 0;