tfussell / xlnt Goto Github PK
View Code? Open in Web Editor NEW:bar_chart: Cross-platform user-friendly xlsx library for C++11+
License: Other
:bar_chart: Cross-platform user-friendly xlsx library for C++11+
License: Other
Somehow works even now, but too funny.
I have a LibreOffice edited xlsx having cells with both English and Chinese characters.
English characters are have Arial
font.
Chinese characters are have Microsoft Yahei
font.
When I print the cell using follow code, I only get the first part of the full cell.
xlnt::workbook wb;
wb.load(filename);
for(auto row : wb[sheet].rows())
{
for(auto cell : row)
{
std::cout << cell << std::endl;
}
}
As in follow image:
abc中文
in cell A1
, abc
has Arial
font and 中文
has Microsoft Yahei
font, I only get abc
print out.汉字def
in cell A2
, 汉字
has Microsoft Yahei
font and 中文
has Arial
font, I only get 汉字
print out.Attachment: bug.xlsx.
Some iterators use templates to reduce code repetition between const and non-const iterators. It would be more correct to have separate classes even if some code is repeated. Also, iterators should inherit from std::iterator with the appropriate std::input_iterator_tag so they can be used in range-based functions.
std::string cell::check_string(const std::string &to_check)
fails to validate utf-8 strings containing multibyte sequences. For example, it fails to validate the following (valid) utf-8 string: "\xc3\xa0"
Hi again,
Been a while but getting back to this now. Just tried compiling with the latest version and getting this error:
import.cpp:450:69: error: invalid use of incomplete type ‘struct xlnt::date’
auto dt = row[i].get_value<xlnt::date>();
^
In file included from /usr/include/xlnt/xlnt.hpp:26:0,
from import.hpp:9,
from import.cpp:7:
/usr/include/xlnt/cell/cell.hpp:49:8: note: forward declaration of ‘struct xlnt::date’
struct date;
^
This is fixed by adding an #include
for utils/date.hpp
into xlnt.hpp
. Hopefully you can add this!
hello .
next is my example code
int _tmain(int argc, _TCHAR* argv[])
{
xlnt::workbook wb2;
if (!wb2.load("book2.xlsx"))
{
std::cout << "can not open book2.xlsx" << std::endl;
return 0;
}
// no need to use references, iterators are only wrappers around pointers to memory in the workbook
for (auto row : wb2.get_sheet_by_name("Sheet2").rows())
{
for (auto cell : row)
{
std::cout << cell.get_value().to_string() << std::endl;
}
}
return 0;
}
Hi again!
I've just discovered that you get some out-of-range vector errors if you try to reopen a file previously saved by xlnt.
For example, now #9 is fixed, running the .xlsx I attached there produces book2.xlsx
without any complaint. However renaming this to book.xlsx
and running it through the same sample1
again causes an exception to be thrown instead. It looks like there is some confusion about how many sheets are in the workbook?
I have noticed that the fix to #9 causes saved sheets to change order (compared to the source document) so I'm wondering whether reloading this workbook (once the sheets have shifted around) causes some sheets to be dropped?
Sorry if I'm not explaining this very well. If you download book2.xlsx
from the link above and feed that into sample1.cpp
then you should be able to reproduce the issue!
Note that this book2.xlsx
is reported by MS Excel as corrupted (possibly due to the missing-formats issue) but all the sheets are read and contain data. But it means there could be two causes for the xlnt exception - either this file is not being read properly, or the previous step (the process in issue #9) doesn't write the file properly.
Let me know if you need any more info. Thanks!
Hi again,
I just updated to the latest git but I'm getting a bunch of xlnt::string
errors in my code now:
cannot convert ‘xlnt::cell_reference::to_string() const()’ (type ‘xlnt::string’) to type ‘const unsigned char*’
<< row[xxx].get_reference().to_string()
note: ‘xlnt::string’ is not derived from ‘const otl_value<TData>’
no known conversion for argument 2 from ‘xlnt::string’ to ‘const IField*’
no known conversion for argument 2 from ‘xlnt::string’ to ‘const current_time&’
error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘xlnt::string’)
/usr/include/c++/5.1.0/bits/basic_string.h:5167:5: note: template argument deduction/substitution failed:
note: ‘xlnt::string’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
Is it no longer possible to use std::string
with xlnt?
Release 0.9.0 for Windows (static 32-bit, dll 32-bit, static 64-bit, dll 32-bit), Ubuntu 14.04 64-bit (static, shared), OSX 10.11 (static, dylib, framework).
Build environment:
Windows 10 x64
xlnt commit: 8970bfa
CMake 3.5.2 (STATIC BUILD)
Visual studio 2015
Microsoft Excel 2016 (16.0.7070.2022)
I wrote simple code to create empty workbook.
#include <iostream>
#define XLNT_STATIC
#include <xlnt\xlnt.hpp>
#ifdef _DEBUG
#pragma comment(lib, "xlntd.lib")
#else
#pragma comment(lib, "xlnt.lib")
#endif
int main(int argc, char *argv[]) {
xlnt::workbook wb;
wb.save("test.xlsx");
return 0;
}
But when I opened 'test.xlsx' file using Excel, Excel said:
Excel cannot open the file 'test.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Is my code wrong? Then how can I create empty workbook which only has one empty worksheet.
Some large XLSXs are 20M large, with ≈50M data, 200M XML, and DOM does not fit into 32-bit memory at all. The only way to parse them in reasonable way is a stream-based parser, like Java StAX.
Documentation feels a little scattered/unfinished. It should be more focused on how to use the library. Generally:
I've got "'xlnt::worksheet::get_cell': no overloaded function takes 2 arguments" error in VS2015. A method with cell reference argument only is currently present in the source.
I was trying to build an example from "Write a workbook" tutorial and stumbled upon this error on line
ws2.get_cell(column, row).set_value(column.column_string());
Ultimately, I was able to run it simply fixing the arguments to something currently supported:
ws2.get_cell(column.column_string() + std::to_string(row)).set_value(column.column_string());
Still, the way presented in the example is neater and is something I would love to see in the final version.
Thank you in advance.
Just tried to test with my own code, and while the samples work, it looks like the spreadsheet I am using does not:
Catchpoint 1 (exception thrown), __cxxabiv1::__cxa_throw (obj=0x7f3a40, tinfo=0x6d93f8 <typeinfo for std::out_of_range@@GLIBCXX_3.4>, dest=0x7ffff3af71c0 <std::out_of_range::~out_of_range()>)
at /build/gcc/src/gcc-5-20150519/libstdc++-v3/libsupc++/eh_throw.cc:62
62 in /build/gcc/src/gcc-5-20150519/libstdc++-v3/libsupc++/eh_throw.cc
(gdb) bt
#0 __cxxabiv1::__cxa_throw (obj=0x7f3a40, tinfo=0x6d93f8 <typeinfo for std::out_of_range@@GLIBCXX_3.4>, dest=0x7ffff3af71c0 <std::out_of_range::~out_of_range()>)
at /build/gcc/src/gcc-5-20150519/libstdc++-v3/libsupc++/eh_throw.cc:62
#1 0x00007ffff3b0aa3f in std::__throw_out_of_range (__s=0x7ffff3f97383 "_Map_base::at") at /build/gcc/src/gcc-5-20150519/libstdc++-v3/src/c++11/functexcept.cc:90
#2 0x00007ffff3f5bd4d in std::__detail::_Map_base<unsigned int, std::pair<unsigned int const, xlnt::column_properties>, std::allocator<std::pair<unsigned int const, xlnt::column_properties> >, std::__detail::_Select1st, std::equal_to<unsigned int>, std::hash<unsigned int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true>, true>::at (
this=0x98a538, __k=@0x7fffffffc0c4: 10) at /usr/include/c++/5.1.0/bits/hashtable_policy.h:646
#3 0x00007ffff3f5a841 in std::unordered_map<unsigned int, xlnt::column_properties, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<std::pair<unsigned int const, xlnt::column_properties> > >::at (
this=0x98a538, __k=@0x7fffffffc0c4: 10) at /usr/include/c++/5.1.0/bits/unordered_map.h:647
#4 0x00007ffff3f59925 in xlnt::worksheet::get_column_properties (this=0x7fffffffd4e0, column=10) at worksheet/worksheet.cpp:724
#5 0x00007ffff3f21120 in xlnt::worksheet_serializer::write_worksheet (this=0x7fffffffd4e0) at serialization/worksheet_serializer.cpp:323
#6 0x00007ffff3eeb4d0 in xlnt::excel_serializer::write_worksheets (this=0x7fffffffd800) at serialization/excel_serializer.cpp:235
#7 0x00007ffff3eeb03a in xlnt::excel_serializer::write_data (this=0x7fffffffd800) at serialization/excel_serializer.cpp:219
#8 0x00007ffff3eeb6a5 in xlnt::excel_serializer::save_workbook (this=0x7fffffffd800, filename=..., as_template=false) at serialization/excel_serializer.cpp:258
#9 0x00007ffff3f38f1f in xlnt::workbook::save (this=0x7fffffffdbb0, filename=...) at workbook/workbook.cpp:483
#10 0x00000000004304ab in main (iArgC=7, cArgV=0x7fffffffe2a8) at main.cpp:206
(gdb) fr 4
#4 0x00007ffff3f59925 in xlnt::worksheet::get_column_properties (this=0x7fffffffd4e0, column=10) at worksheet/worksheet.cpp:724
724 return d_->column_properties_.at(column);
(gdb) print column
$1 = 10
(gdb) fr 5
#5 0x00007ffff3f21120 in xlnt::worksheet_serializer::write_worksheet (this=0x7fffffffd4e0) at serialization/worksheet_serializer.cpp:323
323 const auto &props = sheet_.get_column_properties(column);
(gdb) print sheet_.has_column_properties(10)
$2 = false
My guess is that a column has no properties but the code is trying to retrieve them anyway?
Coveralls will provide an indicator of test coverage.
If a spreadsheet produced by Excel has duplicate strings, xlnt throws an exception when the spreadsheet is opened.
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 5413) >= this->size() (which is 5412)
It is caused when the code tries to reference a shared string, but somehow the shared string has been lost, so the index given in the XML file is out of range.
I have narrowed down the cause of this to the same string being listed more than once in the shared strings XML file. It seems a mistake to have two identical strings here (defeats the purpose of having shared strings in the first place), however this is how Excel saves the file, so it would be nice if xlnt could work around the bug and read the file anyway.
I have created a test case that demonstrates this problem, which I will add below as a pull request.
Tthe EURO SIGN at https://github.com/tfussell/xlnt/blob/master/source/styles/number_format.cpp#L767 not handled by Visual Studio 2015:
1> number_format.cpp
1>D:\Workspace\xlnt\source\styles\number_format.cpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>D:\Workspace\xlnt\source\styles\number_format.cpp(767): error C2001: newline in constant
1>D:\Workspace\xlnt\source\styles\number_format.cpp(768): error C2143: syntax error: missing ';' before '}'
I know that is MS' fault.
Can we use escape sequance \xE2\x82\xAC
, something like:
const std::string EURO_SIGN{ "\xE2\x82\xAC" };
const std::string EURO_LOCALE{ "$\xE2\x82\xAC-407" };
...
else if (format.has_locale && format.locale == EURO_LOCALE)
{
result += EURO_SIGN;
}
Using the write example:
#include<iostream>
#include <xlnt/xlnt.hpp>
using namespace std;
int main()
{
xlnt::workbook wb;
xlnt::worksheet ws = wb.get_active_sheet();
ws.cell("A1").set_value(5);
ws.cell("B2").set_value("string data");
ws.cell("C3").set_formula("=RAND()");
ws.merge_cells("C3:C4");
ws.freeze_panes("B2");
wb.save("book1.xlsx");
return 0;
}
Compiled with:
c++ -o test main.cpp -I ./xlnt/include -std=c++11
throws:
'class xlnt::worksheet' has no member named 'cell'
Was the cell member function removed from the worksheet class at some point?
Synchronize tests for workbook, worksheet, cell, core_properties, manifest, relationship, stylesheet, number_format, format_rule, and tokenizer.
Hi,
I wonder if this tool allows me to provide a hard-code password in C++, and then open and read the password-protected xlsx file?
Thanks,
Nai-Yuan
when i compile it in the vs2012,some error happened,i googled it then i know the vs2012 did not support full c++11,so the error happened.could you please give a vs2012 patch for the source codes,not only zip_file.cpp,but also \xlnt-master\include\xlnt\styles\fill.hpp .
thanks
next is some error log
1> pugixml.cpp
1> zip_file.cpp
1>....\source\zip_file.cpp(12): fatal error C1083: Cannot open include file: 'xlnt/common/zip_file.hpp': No such file or directory
1> writer.cpp
1>....\source\writer.cpp(10): fatal error C1083: Cannot open include file: 'xlnt/writer/writer.hpp': No such file or directory
1> worksheet.cpp
1>....\source\worksheet.cpp(3): fatal error C1083: Cannot open include file: 'xlnt/worksheet/worksheet.hpp': No such file or directory
1> workbook.cpp
1>....\source\workbook.cpp(12): fatal error C1083: Cannot open include file: 'xlnt/workbook/workbook.hpp': No such file or directory
1> value.cpp
1>....\source\value.cpp(3): fatal error C1083: Cannot open include file: 'xlnt/cell/value.hpp': No such file or directory
1> style_writer.cpp
1>....\source\style_writer.cpp(4): fatal error C1083: Cannot open include file: 'xlnt/writer/style_writer.hpp': No such file or directory
1> style.cpp
1>....\source\style.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/styles/style.hpp': No such file or directory
1> string_table.cpp
1>....\source\string_table.cpp(3): fatal error C1083: Cannot open include file: 'xlnt/common/string_table.hpp': No such file or directory
1> sheet_protection.cpp
1>....\source\sheet_protection.cpp(5): fatal error C1083: Cannot open include file: 'xlnt/worksheet/sheet_protection.hpp': No such file or directory
1> relationship.cpp
1>....\source\relationship.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/common/relationship.hpp': No such file or directory
1> reader.cpp
1>....\source\reader.cpp(4): fatal error C1083: Cannot open include file: 'xlnt/reader/reader.hpp': No such file or directory
1> range_reference.cpp
1>....\source\range_reference.cpp(3): fatal error C1083: Cannot open include file: 'xlnt/worksheet/range_reference.hpp': No such file or directory
1> range.cpp
1>....\source\range.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/worksheet/range.hpp': No such file or directory
1> protection.cpp
1>....\source\protection.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/styles/protection.hpp': No such file or directory
1> number_format.cpp
1>....\source\number_format.cpp(3): fatal error C1083: Cannot open include file: 'xlnt/styles/number_format.hpp': No such file or directory
1> exceptions.cpp
1>....\source\exceptions.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/common/exceptions.hpp': No such file or directory
1> drawing.cpp
1>....\source\drawing.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/drawing/drawing.hpp': No such file or directory
1> document_properties.cpp
1>....\source\document_properties.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/workbook/document_properties.hpp': No such file or directory
1> cell_impl.cpp
1>d:\test-xlnt\xlnt-master\xlnt-master\source\detail\cell_impl.hpp(3): fatal error C1083: Cannot open include file: 'xlnt/cell/cell.hpp': No such file or directory
1> Generating Code...
1> Compiling...
1> datetime.cpp
1>....\source\datetime.cpp(4): fatal error C1083: Cannot open include file: 'xlnt/common/datetime.hpp': No such file or directory
1> constants.cpp
1>....\source\constants.cpp(3): fatal error C1083: Cannot open include file: 'xlnt/config.hpp': No such file or directory
1> comment.cpp
1>....\source\comment.cpp(1): fatal error C1083: Cannot open include file: 'xlnt/cell/comment.hpp': No such file or directory
1> cell_reference.cpp
1>....\source\cell_reference.cpp(3): fatal error C1083: Cannot open include file: 'xlnt/cell/cell_reference.hpp': No such file or directory
1> cell.cpp
1>....\source\cell.cpp(5): fatal error C1083: Cannot open include file: 'xlnt/cell/cell.hpp': No such file or directory
I have compiled and installed xlnt as a system library under Linux, however when I try to use the library I have the following problem:
In file included from /usr/include/xlnt-1.0/xlnt/xlnt.hpp:53:
/usr/include/xlnt-1.0/xlnt/common/miniz.h:7:46: fatal error: ../../../third-party/miniz/miniz.c: No such file or directory
It seems miniz.h
has an #include
for the .c
file, whereas really the .c
file has already been compiled into the library and is no longer needed.
Would it be possible to tweak the contents of this file so that xlnt.hpp
can be included by library users without needing to re-include miniz.c
?
Some header files have multiple classes. They should be separated into their own header files.
Would it be possible to add a cmake build configuration setup too?
The follow function not currently implemented:
const worksheet workbook::get_sheet_by_name(const std::string &sheet_name) const;
xlnt::range worksheet::rows(int row_offset, int column_offset) const
During initial development, some methods were written as inline methods in their header files. They should be defined in source files unless there's a good reason.
I try build on Windows 10 in cmake:
cmake -G "MinGW Makefiles" in xlnt root directory and get some errors:
CMake Error at cmake/xlnt.cmake:70 (add_library): Cannot find source file:
../third-party/miniz/miniz.c
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx Call Stack (most recent call first): CMakeLists.txt:74 (include)
CMake Error: CMake can not determine linker language for target: xlnt.shared CMake Error: Cannot determine link language for target "xlnt.shared".
What can I do for cuccess build the library on Windows 10?
Thanks for answer
XML wrappers aren't very pretty, improve them?
If a spreadsheet has no shared strings (it's rare, but excel can produce such files), an exception is thrown in shared_strings_serializer::read_shared_strings()
Specifically, it's on the line:
auto unique_count = std::stoull(root_node.get_attribute("uniqueCount"));
The solution would be to check if root_node has an "uniqueCount" attribute, else we consider unique_count to be zero.
I can produce a pull request if you want
I'm not sure whether a function implementation is missing, or if this is by design (and I am using it wrong.)
I'm not sure how to read a date value out of a cell. If I do something like this:
auto a = cell.get_value().as<std::string>(); // works fine
auto b = cell.get_value().as<xlnt::date>(); // compiles ok, undefined reference
When I do this, I get:
undefined reference to `xlnt::date xlnt::value::as<xlnt::date>() const'
Is there a different way to retrieve a date value from a date-formatted cell? It looks like I could probably retrieve it as an int
and then use the xlnt::datetime
functions to convert that back to a date, but this is a lot of effort for each date cell that has to be read so I'm hoping there's a possibility that as<xlnt::date>()
can be implemented (and presumably as<xlnt::datetime>()
also) as it would make my date-related code much more readable to be able to call those functions instead.
Alternatively if I am doing this wrong, please let me know how it's done! I checked README.md
and sample1.cpp
but couldn't see any date examples there so hopefully I'm not missing something!
self-explanatory
When I try to compile the library it works fine, but when I try to compile a program that uses the library, I get this error:
undefined reference to `long long xlnt::value::as<long long>() const'
I copied the implementation of value::as<int64_t>()
in value.cpp
and changed int64_t
to long long
and it fixed the problem. It looks like the cause might be in writer.cpp
line 428, where value::as<long long>()
gets called.
I guess one of these needs long long
changed to int64_t
or vice versa?
So far, because I was missing the dependencies for the build environment, I've been using GNU Autoconf to produce the Makefiles and install scripts needed to compile and install xlnt on my Linux system, updating the Autoconf scripts myself after every major change.
I notice there are now CMake files, and as CMake is available on my system, I am happy to stop maintaining the Autoconf scripts and move to CMake instead.
However the CMake scripts are currently missing a few features I need, and I'm not familiar enough with CMake to know how to add them:
.pc
filemake install
commandWhile you are welcome to use my Autoconf scripts, assuming CMake is the build system that will be used from now on, would it be possible to add support for the above items? It will make installing and using the library significantly easier under Linux, and will also open the possibility of xlnt being included as an official package in various Linux distributions - something which generally doesn't happen until a library can be compiled and distributed in a somewhat standard way.
For the first point, the pkg-config .pc
file is used by other programs to find the library and link to it, and most libraries supply one. I have created one but it only works with Autoconf so will need some small tweaks to be CMake compatible, mostly with getting the token replacement correct (Autoconf replaces @blah@
with the contents of the blah
variable, I'm not sure what syntax CMake uses to do the same.)
For make install
, I am guessing this is pretty standard as all CMake programs and libraries seem to have support for it, so there is probably some standard statement that will handle that.
For the static library, it would be nice if a shared/dynamic one could be built on platforms that support it. Certainly I have produced a shared library with Autoconf and it works fine, so again this is hopefully just a minor addition to the CMake script.
I hope you'd be willing to consider adding these features to the build process. It would make it much easier for me and other Linux users! Either way, thanks again for all the work you've done on this, and for all the help you've given me - I really appreciate it!
All enums used for serialization should have a map and functions witch look up a string or enum value in that map to convert the enum to/from std::string.
Hi again, sorry about this!
I just tried to read in a spreadsheet generated with PHP_XSLXWriter which opens fine in Excel, but xlnt thinks all the sheets have only one row, and that the cells are blank.
I can't attach it for some reason but you can get it at http://www.shikadi.net/files/book.xlsx. I think PHP_XSLXWriter likes to use shared strings a lot, so I am wondering whether xlnt doesn't support these yet? This is just a guess, I really have no idea!
If you are able to work out what the problem is, do you think it would be a relatively easy fix, or will it be a bigger issue to resolve? Thanks again!
The README
says pugixml is "included in the source tree for convenience" but it looks like an empty folder.
I can't see any downloadable releases, so I am not sure whether I am supposed to clone the pugixml repository into third-party/
(ending up with third-party/pugixml/src/pugixml.cpp
) or whether I am supposed to extract the .cpp files and place them directly in the empty folder (ending up with third-party/pugixml/pugixml.cpp
without a src/
folder in the middle there.)
Where should the pugixml files go?
As I said, some large XLSXs are 20M large, with ≈50M in-memory data, 200M XML, and DOM >1G.
It’s rather hard to dispose of 200M, but it’s much easier to dispose of 1G, writing XML tag by tag, without building DOM structure.
I don’t know how it is in Linux, but in Windows we’ll need wchar_t* / wstring filenames.
While trying to test read.cpp sample with "sample1.xlsx", libstudxml throw an xml::parsing exception from xlsx_consumer.cpp l.801:
view.tab_ratio = string_to_size_t(parser.attribute("tabRatio"));
Is it up to the user to catch internal xml::parsing exceptions ?
(BTW: There is no error reported while running tests, the problem is probably related to my test build environment: MSVC2015 U2 + qmake/qtcreator in Debug mode trying to link default xlnt.lib generated by cmake with incompatible options)
Just tried compiling the latest git version (e3bb0be) to report back on the other issues, but I'm getting a few compile errors (gcc 5.1.0 under Linux)
In file included from ../include/xlnt/cell/../styles/style.hpp:28:0,
from ../include/xlnt/cell/cell.hpp:30,
from comment.cpp:1:
../include/xlnt/cell/../styles/borders.hpp:97:24: error: declaration of ‘xlnt::diagonal_direction xlnt::border::diagonal_direction’ [-fpermissive]
diagonal_direction diagonal_direction;
^
../include/xlnt/cell/../styles/borders.hpp:55:12: error: changes meaning of ‘diagonal_direction’ from ‘enum class xlnt::diagonal_direction’ [-fpermissive]
enum class diagonal_direction
^
I can fix this error by doing this:
--- a/include/xlnt/styles/borders.hpp
+++ b/include/xlnt/styles/borders.hpp
@@ -94,7 +94,7 @@ public:
bool diagonal_up;
bool diagonal_down;
- diagonal_direction diagonal_direction;
+ xlnt::diagonal_direction diagonal_direction;
I also got this error:
cell.cpp:143:6: error: prototype for ‘void xlnt::cell::set_value(long long int)’ does not match any in class ‘xlnt::cell’
void cell::set_value(long long i)
^
In file included from cell.cpp:5:0:
../include/xlnt/cell/cell.hpp:87:10: error: candidate is: template<class T> void xlnt::cell::set_value(T)
void set_value(T value);
^
cell.cpp:150:6: error: prototype for ‘void xlnt::cell::set_value(long long unsigned int)’ does not match any in class ‘xlnt::cell’
void cell::set_value(unsigned long long i)
^
In file included from cell.cpp:5:0:
../include/xlnt/cell/cell.hpp:87:10: error: candidate is: template<class T> void xlnt::cell::set_value(T)
void set_value(T value);
^
Which was fixed by doing this:
--- a/source/cell.cpp
+++ b/source/cell.cpp
@@ -140,6 +140,7 @@ void cell::set_value(unsigned long i)
#endif
#ifdef __linux__
+template <>
void cell::set_value(long long i)
{
d_->is_date_ = false;
@@ -147,6 +148,7 @@ void cell::set_value(long long i)
d_->type_ = type::numeric;
}
+template <>
void cell::set_value(unsigned long long i)
{
d_->is_date_ = false;
Looks like those lines were just missed during a bulk change. There's another line inside an #ifdef _WIN32
(just above these changes) which probably has to be updated as well.
Hi - just trying out the latest git version, and I get these errors when compiling now:
workbook/manifest.cpp: In member function ‘std::string xlnt::manifest::get_default_type(const string&) const’
workbook/manifest.cpp:105:15: error: ‘runtime_error’ is not a member of ‘std’
throw std::runtime_error("no default type found for extension: " + extension);
^
workbook/manifest.cpp: In member function ‘std::string xlnt::manifest::get_override_type(const string&) const’
workbook/manifest.cpp:118:15: error: ‘runtime_error’ is not a member of ‘std’
throw std::runtime_error("no default type found for part name: " + part_name);
Which I fixed by doing this:
diff --git a/source/workbook/manifest.cpp b/source/workbook/manifest.cpp
index 1209ef1..1ea5ba0 100644
--- a/source/workbook/manifest.cpp
+++ b/source/workbook/manifest.cpp
@@ -1,5 +1,6 @@
#include <algorithm>
+#include <xlnt/common/exceptions.hpp>
#include <xlnt/workbook/manifest.hpp>
namespace {
Potential users might want to know what they can do and what remains to be implemented when deciding to use this library.
Sorry about spamming you with issues :-)
If you take docs/sample/sample1.cpp
and change this line:
xlnt::workbook workbook;
to this:
xlnt::workbook workbook = xlnt::reader::load_workbook("book.xlsx");
Then when you run the code, you get an unhandled exception error:
terminate called after throwing an instance of 'std::invalid_argument'
what(): stoi
The exception looks like it's got something to do with calculating the sheet index from the filename:
#9 0x00007ffff7b54f9e in xlnt::writer::write_workbook (wb=...) at writer.cpp:172
172 std::size_t sheet_index = std::stoi(sheet_index_string.substr(0, sheet_index_string.find('.'))) - 1;
(gdb) print sheet_index_string
$1 = "eet1.xml"
It looks like the input file, produced by MS Excel, has a filename in a format that xlnt isn't expecting?
std::stoi()
seems to be encountering the e
at the start of the string and then throwing std::invalid_argument
, since it can only handle digits and leading whitespace.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.