react-native-nitro-xlsx 0.1.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NitroXlsx.podspec +27 -27
- package/Package.swift +35 -10
- package/README.md +220 -58
- package/android/CMakeLists.txt +24 -27
- package/android/cpp-adapter.cpp +12 -0
- package/android/src/main/java/com/margelo/nitro/xlsx/NitroXlsxPackage.kt +9 -0
- package/cpp/HybridNitroXlsx.cpp +25 -179
- package/cpp/HybridNitroXlsx.hpp +2 -2
- package/cpp/HybridXlsxConditionalFormat.cpp +252 -0
- package/cpp/HybridXlsxConditionalFormat.hpp +62 -0
- package/cpp/HybridXlsxConditionalFormats.cpp +46 -0
- package/cpp/HybridXlsxConditionalFormats.hpp +28 -0
- package/cpp/HybridXlsxWorkbook.cpp +159 -196
- package/cpp/HybridXlsxWorkbook.hpp +7 -2
- package/cpp/HybridXlsxWorksheet.cpp +433 -62
- package/cpp/HybridXlsxWorksheet.hpp +73 -26
- package/cpp/XlsxCacheDir.cpp +76 -0
- package/cpp/XlsxCacheDir.hpp +27 -0
- package/cpp/XlsxError.hpp +68 -0
- package/cpp/XlsxJson.cpp +185 -0
- package/cpp/XlsxJson.hpp +36 -0
- package/ios/XlsxCacheDir.mm +60 -0
- package/nitrogen/generated/android/NitroXlsx+autolinking.cmake +2 -0
- package/nitrogen/generated/shared/c++/HybridNitroXlsxSpec.hpp +5 -3
- package/nitrogen/generated/shared/c++/HybridXlsxConditionalFormatSpec.cpp +54 -0
- package/nitrogen/generated/shared/c++/HybridXlsxConditionalFormatSpec.hpp +95 -0
- package/nitrogen/generated/shared/c++/HybridXlsxConditionalFormatsSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridXlsxConditionalFormatsSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/HybridXlsxWorkbookSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridXlsxWorkbookSpec.hpp +6 -1
- package/nitrogen/generated/shared/c++/HybridXlsxWorksheetSpec.cpp +47 -19
- package/nitrogen/generated/shared/c++/HybridXlsxWorksheetSpec.hpp +52 -20
- package/package.json +3 -3
- package/scripts/run-cpp-tests.sh +14 -0
- package/src/__mocks__/react-native-nitro-modules.ts +1 -0
- package/src/__tests__/index.test.ts +76 -7
- package/src/index.ts +107 -18
- package/src/specs/NitroXlsx.nitro.ts +141 -44
- package/thirdparty/OpenXLSX/.clang-format +118 -0
- package/thirdparty/OpenXLSX/.clang-tidy +28 -0
- package/thirdparty/OpenXLSX/.gitignore +130 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_before_XMLNode_wrappers +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_and_stripping +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_char_support +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_support +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespaced_name_disabled +49 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-08-11-benchmarks_post-XLCellIterator-Rework +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-08-14-benchmarks_post-default-row-column-style-support +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-09-02-benchmarks +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-12-19-benchmarks +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2024-12-30-benchmarks-post-XLSharedStrings-by-ref +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-01-09-benchmarks-post-conditionalFormatsAndSheetProtection +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-01-10-benchmarks-post-XLCellValue-bugfix +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-01-31-benchmarks-post-XLComments-implementation +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-02-02-benchmarks-post-XLRowIterator-Rework +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-07-20-benchmarks-after-hiding-pugixml-internals +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/2025-08-29-benchmarks-after-code-review-with-libzip +46 -0
- package/thirdparty/OpenXLSX/Benchmarks/Benchmark.cpp +249 -0
- package/thirdparty/OpenXLSX/Benchmarks/CMakeLists.txt +19 -0
- package/thirdparty/OpenXLSX/CMakeLists.txt +466 -0
- package/thirdparty/OpenXLSX/Documentation/CMakeLists.txt +31 -0
- package/thirdparty/OpenXLSX/Documentation/Doxyfile.in +2471 -0
- package/thirdparty/OpenXLSX/Documentation/DoxygenLayout.xml +194 -0
- package/thirdparty/OpenXLSX/Documentation/customdoxygen.css +1355 -0
- package/thirdparty/OpenXLSX/Examples/CMakeLists.txt +103 -0
- package/thirdparty/OpenXLSX/Examples/Demo1.cpp +279 -0
- package/thirdparty/OpenXLSX/Examples/Demo10.cpp +545 -0
- package/thirdparty/OpenXLSX/Examples/Demo1A.cpp +137 -0
- package/thirdparty/OpenXLSX/Examples/Demo2.cpp +65 -0
- package/thirdparty/OpenXLSX/Examples/Demo3.cpp +89 -0
- package/thirdparty/OpenXLSX/Examples/Demo4.cpp +86 -0
- package/thirdparty/OpenXLSX/Examples/Demo5.cpp +77 -0
- package/thirdparty/OpenXLSX/Examples/Demo6.cpp +103 -0
- package/thirdparty/OpenXLSX/Examples/Demo7.cpp +79 -0
- package/thirdparty/OpenXLSX/Examples/Demo8.cpp +117 -0
- package/thirdparty/OpenXLSX/Examples/Demo9.cpp +363 -0
- package/thirdparty/OpenXLSX/Examples/cmake/FindLIBZIP.cmake +61 -0
- package/thirdparty/OpenXLSX/Examples/external/CustomZip/CustomZip.hpp +256 -0
- package/thirdparty/OpenXLSX/LICENSE.md +29 -0
- package/thirdparty/OpenXLSX/Makefile.GNU +530 -0
- package/thirdparty/OpenXLSX/Notes/TBDs.txt +16 -0
- package/thirdparty/OpenXLSX/Notes/confirmed-TBCs.txt +8 -0
- package/thirdparty/OpenXLSX/Notes/styles-missing-support.xml +12 -0
- package/thirdparty/OpenXLSX/Notes/todo-list.txt +108 -0
- package/thirdparty/OpenXLSX/OpenXLSX/CMakeLists.txt +631 -0
- package/thirdparty/OpenXLSX/OpenXLSX/OpenXLSX.hpp +63 -0
- package/thirdparty/OpenXLSX/OpenXLSX/OpenXLSXConfig.cmake +11 -0
- package/thirdparty/OpenXLSX/OpenXLSX/cmake/bundle_static_library.cmake +198 -0
- package/thirdparty/OpenXLSX/OpenXLSX/cmake/patch_pkg_config.cmake +69 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/IZipArchive.hpp +361 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX-Exports.hpp +12 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCell.hpp +367 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellIterator.hpp +252 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellRange.hpp +223 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellReference.hpp +317 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellValue.hpp +793 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLColor.hpp +232 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLColumn.hpp +159 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCommandQuery.hpp +228 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLComments.hpp +270 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLConstants.hpp +18 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLContentTypes.hpp +264 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDateTime.hpp +175 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDocument.hpp +505 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDrawing.hpp +452 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLException.hpp +161 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLFormula.hpp +375 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLIterator.hpp +40 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLMergeCells.hpp +216 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLProperties.hpp +348 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRelationships.hpp +348 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRow.hpp +721 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRowData.hpp +488 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLSharedStrings.hpp +204 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLSheet.hpp +1640 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLStyles.hpp +2390 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLTables.hpp +132 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLWorkbook.hpp +404 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlData.hpp +283 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlFile.hpp +194 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlParser.hpp +282 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlParserForwardDeclarations.hpp +85 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/XLZipArchive.hpp +232 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/LibZip.hpp +447 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/OpenXLSXFileSystemTools.hpp +207 -0
- package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/Zippy.hpp +1375 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCell.cpp +340 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellIterator.cpp +427 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellRange.cpp +221 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellReference.cpp +408 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellValue.cpp +519 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLColor.cpp +202 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLColumn.cpp +141 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLComments.cpp +637 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLContentTypes.cpp +329 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDateTime.cpp +269 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDocument.cpp +1678 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDrawing.cpp +784 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLFormula.cpp +201 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLMergeCells.cpp +357 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLProperties.cpp +810 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRelationships.cpp +529 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRow.cpp +918 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRowData.cpp +508 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLSharedStrings.cpp +220 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLSheet.cpp +1970 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLStyles.cpp +3014 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLTables.cpp +125 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLWorkbook.cpp +784 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlData.cpp +247 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlFile.cpp +160 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlParser.cpp +261 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/XLZipArchive.cpp +266 -0
- package/thirdparty/OpenXLSX/OpenXLSX/sources/utilities/XLUtilities.hpp +478 -0
- package/thirdparty/OpenXLSX/README.md +1279 -0
- package/thirdparty/OpenXLSX/Scripts/cmake-cleanup.sh +102 -0
- package/thirdparty/OpenXLSX/Scripts/compile.sh +23 -0
- package/thirdparty/OpenXLSX/Scripts/demos-cleanup.sh +25 -0
- package/thirdparty/OpenXLSX/Scripts/demos-run-all.sh +60 -0
- package/thirdparty/OpenXLSX/Scripts/guarded-xml-format.sh +47 -0
- package/thirdparty/OpenXLSX/Scripts/make-gnu.sh +11 -0
- package/thirdparty/OpenXLSX/Scripts/uninstall-manifest.sh +48 -0
- package/thirdparty/OpenXLSX/Scripts/xml-format-all.sh +19 -0
- package/thirdparty/OpenXLSX/Scripts/xml-format.sh +38 -0
- package/thirdparty/OpenXLSX/Tests/CMakeLists.txt +37 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch.hpp +17799 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_automake.hpp +68 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_sonarqube.hpp +182 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_tap.hpp +278 -0
- package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_teamcity.hpp +212 -0
- package/thirdparty/OpenXLSX/Tests/main.cpp +55 -0
- package/thirdparty/OpenXLSX/Tests/testXLCell.cpp +176 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellRange.cpp +180 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellReference.cpp +160 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellValue.cpp +366 -0
- package/thirdparty/OpenXLSX/Tests/testXLCellValueProxy.cpp +255 -0
- package/thirdparty/OpenXLSX/Tests/testXLColor.cpp +75 -0
- package/thirdparty/OpenXLSX/Tests/testXLDateTime.cpp +229 -0
- package/thirdparty/OpenXLSX/Tests/testXLDocument.cpp +197 -0
- package/thirdparty/OpenXLSX/Tests/testXLFormula.cpp +131 -0
- package/thirdparty/OpenXLSX/Tests/testXLRow.cpp +597 -0
- package/thirdparty/OpenXLSX/Tests/testXLSheet.cpp +77 -0
- package/thirdparty/OpenXLSX/Tests/ziptest-with-libs.cpp +88 -0
- package/thirdparty/OpenXLSX/Tests/ziptest.cpp +735 -0
- package/thirdparty/OpenXLSX/cmake/get-git-HEAD-ID.cmake +45 -0
- package/thirdparty/OpenXLSX/cmake/libopenxlsxCPackOptions.cmake.in +20 -0
- package/thirdparty/OpenXLSX/cmake/manage_dependency.cmake +813 -0
- package/thirdparty/OpenXLSX/cmake/recursive_library_type_test.cmake +52 -0
- package/thirdparty/OpenXLSX/gnu-make-crutch/OpenXLSX-Exports-shared.hpp +42 -0
- package/thirdparty/OpenXLSX/gnu-make-crutch/OpenXLSX-Exports-static.hpp +42 -0
- package/thirdparty/OpenXLSX/vcpkg.json +24 -0
- package/thirdparty/README.md +42 -0
- package/thirdparty/miniz/.clang-format +47 -0
- package/thirdparty/miniz/.travis.yml +2 -0
- package/thirdparty/miniz/CMakeLists.txt +333 -0
- package/thirdparty/miniz/CMakePresets.json +31 -0
- package/thirdparty/miniz/ChangeLog.md +272 -0
- package/thirdparty/miniz/Config.cmake.in +1 -0
- package/thirdparty/miniz/LICENSE +22 -0
- package/thirdparty/miniz/amalgamate.sh +57 -0
- package/thirdparty/miniz/examples/example1.c +105 -0
- package/thirdparty/miniz/examples/example2.c +164 -0
- package/thirdparty/miniz/examples/example3.c +269 -0
- package/thirdparty/miniz/examples/example4.c +102 -0
- package/thirdparty/miniz/examples/example5.c +327 -0
- package/thirdparty/miniz/examples/example6.c +189 -0
- package/thirdparty/miniz/meson.build +21 -0
- package/thirdparty/miniz/miniz.c +646 -0
- package/thirdparty/miniz/miniz.h +615 -0
- package/thirdparty/miniz/miniz.pc.in +13 -0
- package/thirdparty/miniz/miniz_common.h +89 -0
- package/thirdparty/miniz/miniz_export.h +20 -0
- package/thirdparty/miniz/miniz_tdef.c +1602 -0
- package/thirdparty/miniz/miniz_tdef.h +199 -0
- package/thirdparty/miniz/miniz_tinfl.c +778 -0
- package/thirdparty/miniz/miniz_tinfl.h +150 -0
- package/thirdparty/miniz/miniz_zip.c +4895 -0
- package/thirdparty/miniz/miniz_zip.h +454 -0
- package/thirdparty/miniz/readme.md +46 -0
- package/thirdparty/miniz/test.sh +36 -0
- package/thirdparty/miniz/tests/add_in_place_fuzzer.c +87 -0
- package/thirdparty/miniz/tests/catch_amalgamated.cpp +10795 -0
- package/thirdparty/miniz/tests/catch_amalgamated.hpp +13143 -0
- package/thirdparty/miniz/tests/checksum_fuzzer.c +26 -0
- package/thirdparty/miniz/tests/compress_fuzzer.c +91 -0
- package/thirdparty/miniz/tests/flush_fuzzer.c +88 -0
- package/thirdparty/miniz/tests/fuzz_main.c +55 -0
- package/thirdparty/miniz/tests/large_fuzzer.c +133 -0
- package/thirdparty/miniz/tests/main.cpp +185 -0
- package/thirdparty/miniz/tests/miniz_tdefl_fuzzer.cc +115 -0
- package/thirdparty/miniz/tests/miniz_tester.cpp +1881 -0
- package/thirdparty/miniz/tests/miniz_zip_validate_fuzzer.cc +71 -0
- package/thirdparty/miniz/tests/miniz_zip_writer_fuzzer.cc +96 -0
- package/thirdparty/miniz/tests/ossfuzz.sh +48 -0
- package/thirdparty/miniz/tests/small_fuzzer.c +126 -0
- package/thirdparty/miniz/tests/timer.cpp +152 -0
- package/thirdparty/miniz/tests/timer.h +40 -0
- package/thirdparty/miniz/tests/uncompress2_fuzzer.c +21 -0
- package/thirdparty/miniz/tests/uncompress_fuzzer.c +30 -0
- package/thirdparty/miniz/tests/zip.dict +9 -0
- package/thirdparty/miniz/tests/zip_fuzzer.c +63 -0
- package/thirdparty/pugixml/.codecov.yml +7 -0
- package/thirdparty/pugixml/.gitattributes +1 -0
- package/thirdparty/pugixml/CMakeLists.txt +330 -0
- package/thirdparty/pugixml/LICENSE.md +24 -0
- package/thirdparty/pugixml/Makefile +98 -0
- package/thirdparty/pugixml/README.md +81 -0
- package/thirdparty/pugixml/SECURITY.md +9 -0
- package/thirdparty/pugixml/appveyor.yml +50 -0
- package/thirdparty/pugixml/docs/config.adoc +7 -0
- package/thirdparty/pugixml/docs/images/dom_tree.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_link1.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_link2.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch1.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch2.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch3.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2005_pch4.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2010_link1.png +0 -0
- package/thirdparty/pugixml/docs/images/vs2010_link2.png +0 -0
- package/thirdparty/pugixml/docs/manual.adoc +3326 -0
- package/thirdparty/pugixml/docs/manual.html +6395 -0
- package/thirdparty/pugixml/docs/quickstart.adoc +287 -0
- package/thirdparty/pugixml/docs/quickstart.html +1107 -0
- package/thirdparty/pugixml/docs/samples/character.xml +8 -0
- package/thirdparty/pugixml/docs/samples/custom_memory_management.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/include.cpp +64 -0
- package/thirdparty/pugixml/docs/samples/load_error_handling.cpp +33 -0
- package/thirdparty/pugixml/docs/samples/load_file.cpp +16 -0
- package/thirdparty/pugixml/docs/samples/load_memory.cpp +66 -0
- package/thirdparty/pugixml/docs/samples/load_options.cpp +30 -0
- package/thirdparty/pugixml/docs/samples/load_stream.cpp +97 -0
- package/thirdparty/pugixml/docs/samples/modify_add.cpp +29 -0
- package/thirdparty/pugixml/docs/samples/modify_base.cpp +43 -0
- package/thirdparty/pugixml/docs/samples/modify_remove.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/save_custom_writer.cpp +116 -0
- package/thirdparty/pugixml/docs/samples/save_declaration.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/save_file.cpp +17 -0
- package/thirdparty/pugixml/docs/samples/save_options.cpp +48 -0
- package/thirdparty/pugixml/docs/samples/save_stream.cpp +18 -0
- package/thirdparty/pugixml/docs/samples/save_subtree.cpp +26 -0
- package/thirdparty/pugixml/docs/samples/text.cpp +35 -0
- package/thirdparty/pugixml/docs/samples/transitions.xml +7 -0
- package/thirdparty/pugixml/docs/samples/traverse_base.cpp +51 -0
- package/thirdparty/pugixml/docs/samples/traverse_iter.cpp +27 -0
- package/thirdparty/pugixml/docs/samples/traverse_predicate.cpp +48 -0
- package/thirdparty/pugixml/docs/samples/traverse_rangefor.cpp +32 -0
- package/thirdparty/pugixml/docs/samples/traverse_walker.cpp +35 -0
- package/thirdparty/pugixml/docs/samples/tree.xml +12 -0
- package/thirdparty/pugixml/docs/samples/weekly-shift_jis.xml +78 -0
- package/thirdparty/pugixml/docs/samples/weekly-utf-16.xml +0 -0
- package/thirdparty/pugixml/docs/samples/weekly-utf-8.xml +78 -0
- package/thirdparty/pugixml/docs/samples/xgconsole.xml +12 -0
- package/thirdparty/pugixml/docs/samples/xpath_error.cpp +43 -0
- package/thirdparty/pugixml/docs/samples/xpath_query.cpp +36 -0
- package/thirdparty/pugixml/docs/samples/xpath_select.cpp +28 -0
- package/thirdparty/pugixml/docs/samples/xpath_variables.cpp +38 -0
- package/thirdparty/pugixml/readme.txt +50 -0
- package/thirdparty/pugixml/scripts/archive.py +54 -0
- package/thirdparty/pugixml/scripts/cocoapods_push.sh +4 -0
- package/thirdparty/pugixml/scripts/natvis/pugixml.natvis +77 -0
- package/thirdparty/pugixml/scripts/natvis/pugixml_compact.natvis +506 -0
- package/thirdparty/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml +17 -0
- package/thirdparty/pugixml/scripts/nuget/build/native/pugixml.targets +28 -0
- package/thirdparty/pugixml/scripts/nuget/pugixml.nuspec +20 -0
- package/thirdparty/pugixml/scripts/nuget_build.ps1 +60 -0
- package/thirdparty/pugixml/scripts/premake4.lua +92 -0
- package/thirdparty/pugixml/scripts/pugixml-config.cmake.in +12 -0
- package/thirdparty/pugixml/scripts/pugixml.pc.in +11 -0
- package/thirdparty/pugixml/scripts/pugixml.podspec +14 -0
- package/thirdparty/pugixml/scripts/pugixml.xcodeproj/project.pbxproj +212 -0
- package/thirdparty/pugixml/scripts/pugixml_airplay.mkf +13 -0
- package/thirdparty/pugixml/scripts/pugixml_codeblocks.cbp +44 -0
- package/thirdparty/pugixml/scripts/pugixml_codelite.project +56 -0
- package/thirdparty/pugixml/scripts/pugixml_dll.rc +45 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2005.vcproj +343 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2005_static.vcproj +343 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2008.vcproj +339 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2008_static.vcproj +339 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2010.vcxproj +191 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2010_static.vcxproj +191 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2013.vcxproj +199 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2013_static.vcxproj +199 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2015.vcxproj +172 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2015_static.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2017.vcxproj +172 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2017_static.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2019.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2019_static.vcxproj +180 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2022.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2022_static.vcxproj +180 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2026.vcxproj +176 -0
- package/thirdparty/pugixml/scripts/pugixml_vs2026_static.vcxproj +180 -0
- package/thirdparty/pugixml/scripts/sbom.cdx.json +47 -0
- package/thirdparty/pugixml/src/pugiconfig.hpp +81 -0
- package/thirdparty/pugixml/src/pugixml.cpp +13776 -0
- package/thirdparty/pugixml/src/pugixml.hpp +1604 -0
- package/thirdparty/pugixml/tests/allocator.cpp +175 -0
- package/thirdparty/pugixml/tests/allocator.hpp +10 -0
- package/thirdparty/pugixml/tests/autotest-appveyor.ps1 +93 -0
- package/thirdparty/pugixml/tests/cmake-appveyor.ps1 +57 -0
- package/thirdparty/pugixml/tests/data/empty.xml +0 -0
- package/thirdparty/pugixml/tests/data/large.xml +1 -0
- package/thirdparty/pugixml/tests/data/latintest_latin1.xml +1 -0
- package/thirdparty/pugixml/tests/data/latintest_utf8.xml +1 -0
- package/thirdparty/pugixml/tests/data/multiline.xml +3 -0
- package/thirdparty/pugixml/tests/data/small.xml +1 -0
- package/thirdparty/pugixml/tests/data/truncation.xml +19 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_be_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf16_le_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_be_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le_bom.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le_clean.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf32_le_nodecl.xml +0 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8.xml +87 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8_bom.xml +87 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8_clean.xml +84 -0
- package/thirdparty/pugixml/tests/data/utftest_utf8_nodecl.xml +86 -0
- package/thirdparty/pugixml/tests/data//321/202/320/265/321/201/321/202.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/basic.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/doctype.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/refs.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/types.xml +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/utf16.xml +0 -0
- package/thirdparty/pugixml/tests/data_fuzz_parse/utf32.xml +0 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/basic.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/functions.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/math.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/path.xpath +1 -0
- package/thirdparty/pugixml/tests/data_fuzz_xpath/predicate.xpath +1 -0
- package/thirdparty/pugixml/tests/fuzz_parse.cpp +14 -0
- package/thirdparty/pugixml/tests/fuzz_parse.dict +72 -0
- package/thirdparty/pugixml/tests/fuzz_setup.sh +11 -0
- package/thirdparty/pugixml/tests/fuzz_xpath.cpp +46 -0
- package/thirdparty/pugixml/tests/fuzz_xpath.dict +72 -0
- package/thirdparty/pugixml/tests/helpers.hpp +114 -0
- package/thirdparty/pugixml/tests/main.cpp +218 -0
- package/thirdparty/pugixml/tests/test.cpp +220 -0
- package/thirdparty/pugixml/tests/test.hpp +175 -0
- package/thirdparty/pugixml/tests/test_compact.cpp +150 -0
- package/thirdparty/pugixml/tests/test_deprecated.cpp +25 -0
- package/thirdparty/pugixml/tests/test_document.cpp +1910 -0
- package/thirdparty/pugixml/tests/test_dom_modify.cpp +2122 -0
- package/thirdparty/pugixml/tests/test_dom_text.cpp +601 -0
- package/thirdparty/pugixml/tests/test_dom_traverse.cpp +1481 -0
- package/thirdparty/pugixml/tests/test_header_guard.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iosfwd_1.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iosfwd_2.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iostream_1.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_iostream_2.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_only_1.cpp +21 -0
- package/thirdparty/pugixml/tests/test_header_only_2.cpp +21 -0
- package/thirdparty/pugixml/tests/test_header_string_1.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_string_2.cpp +3 -0
- package/thirdparty/pugixml/tests/test_header_string_iostream.cpp +5 -0
- package/thirdparty/pugixml/tests/test_memory.cpp +303 -0
- package/thirdparty/pugixml/tests/test_parse.cpp +1463 -0
- package/thirdparty/pugixml/tests/test_parse_doctype.cpp +366 -0
- package/thirdparty/pugixml/tests/test_unicode.cpp +152 -0
- package/thirdparty/pugixml/tests/test_version.cpp +5 -0
- package/thirdparty/pugixml/tests/test_write.cpp +757 -0
- package/thirdparty/pugixml/tests/test_xpath.cpp +833 -0
- package/thirdparty/pugixml/tests/test_xpath_api.cpp +646 -0
- package/thirdparty/pugixml/tests/test_xpath_functions.cpp +844 -0
- package/thirdparty/pugixml/tests/test_xpath_operators.cpp +566 -0
- package/thirdparty/pugixml/tests/test_xpath_parse.cpp +428 -0
- package/thirdparty/pugixml/tests/test_xpath_paths.cpp +787 -0
- package/thirdparty/pugixml/tests/test_xpath_paths_abbrev_w3c.cpp +219 -0
- package/thirdparty/pugixml/tests/test_xpath_paths_w3c.cpp +312 -0
- package/thirdparty/pugixml/tests/test_xpath_variables.cpp +683 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_1.cpp +411 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_2.cpp +417 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_3.cpp +321 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_4.cpp +300 -0
- package/thirdparty/pugixml/tests/test_xpath_xalan_5.cpp +295 -0
- package/thirdparty/pugixml/tests/writer_string.cpp +79 -0
- package/thirdparty/pugixml/tests/writer_string.hpp +27 -0
- package/ios/dummy.swift +0 -2
- package/scripts/prepare-openxlsx.js +0 -109
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#include "HybridXlsxWorkbook.hpp"
|
|
2
|
+
#include "XlsxError.hpp"
|
|
3
|
+
#include "XlsxJson.hpp"
|
|
4
|
+
#include "XlsxCacheDir.hpp"
|
|
2
5
|
#include <stdexcept>
|
|
3
6
|
#include <fstream>
|
|
4
7
|
#include <sstream>
|
|
@@ -6,79 +9,23 @@
|
|
|
6
9
|
#include <unistd.h>
|
|
7
10
|
#include <cmath>
|
|
8
11
|
#include <cstring>
|
|
9
|
-
#include <
|
|
12
|
+
#include <chrono>
|
|
10
13
|
|
|
11
14
|
#ifdef __ANDROID__
|
|
12
15
|
#include <android/api-level.h>
|
|
13
16
|
#include <sys/stat.h>
|
|
14
17
|
#endif
|
|
15
18
|
|
|
16
|
-
namespace {
|
|
17
|
-
|
|
18
|
-
void writeJsonString(std::ostringstream& out, const std::string& s) {
|
|
19
|
-
out << '"';
|
|
20
|
-
for (char c : s) {
|
|
21
|
-
switch (c) {
|
|
22
|
-
case '"': out << "\\\""; break;
|
|
23
|
-
case '\\': out << "\\\\"; break;
|
|
24
|
-
case '\b': out << "\\b"; break;
|
|
25
|
-
case '\f': out << "\\f"; break;
|
|
26
|
-
case '\n': out << "\\n"; break;
|
|
27
|
-
case '\r': out << "\\r"; break;
|
|
28
|
-
case '\t': out << "\\t"; break;
|
|
29
|
-
default:
|
|
30
|
-
if (static_cast<unsigned char>(c) < 0x20) {
|
|
31
|
-
out << "\\u" << std::hex << std::setw(4) << std::setfill('0')
|
|
32
|
-
<< static_cast<int>(static_cast<unsigned char>(c))
|
|
33
|
-
<< std::dec;
|
|
34
|
-
} else {
|
|
35
|
-
out << c;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
out << '"';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
} // anonymous namespace
|
|
43
|
-
|
|
44
19
|
namespace margelo::nitro::xlsx {
|
|
45
20
|
|
|
46
|
-
|
|
47
|
-
std::string getTempDir() {
|
|
48
|
-
#ifdef __ANDROID__
|
|
49
|
-
// /tmp is typically not available in Android sandbox, use app's cache directory
|
|
50
|
-
const char* cacheDir = std::getenv("TMPDIR");
|
|
51
|
-
if (cacheDir != nullptr && cacheDir[0] != '\0') {
|
|
52
|
-
return std::string(cacheDir);
|
|
53
|
-
}
|
|
54
|
-
// Try common Android cache directories
|
|
55
|
-
const char* candidates[] = {
|
|
56
|
-
"/data/local/tmp",
|
|
57
|
-
"/data/data/tmp",
|
|
58
|
-
"/sdcard/tmp",
|
|
59
|
-
"/tmp"
|
|
60
|
-
};
|
|
61
|
-
for (const char* dir : candidates) {
|
|
62
|
-
struct stat st;
|
|
63
|
-
if (stat(dir, &st) == 0 && S_ISDIR(st.st_mode)) {
|
|
64
|
-
return std::string(dir);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return "/data/local/tmp";
|
|
68
|
-
#else
|
|
69
|
-
return "/tmp";
|
|
70
|
-
#endif
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
HybridXlsxWorkbook::HybridXlsxWorkbook(const std::optional<std::string>& tempDir)
|
|
21
|
+
HybridXlsxWorkbook::HybridXlsxWorkbook()
|
|
75
22
|
: HybridObject("XlsxWorkbook"), HybridXlsxWorkbookSpec(), _finalized(false) {
|
|
76
23
|
_workbook = std::make_unique<OpenXLSX::XLDocument>();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
24
|
+
_tempDir = getCacheDir();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
std::string HybridXlsxWorkbook::tempFilePath(const char* prefix) {
|
|
28
|
+
return _tempDir + "/" + prefix + "_" + std::to_string(std::chrono::system_clock::now().time_since_epoch().count()) + ".xlsx";
|
|
82
29
|
}
|
|
83
30
|
|
|
84
31
|
HybridXlsxWorkbook::~HybridXlsxWorkbook() {
|
|
@@ -90,7 +37,7 @@ void HybridXlsxWorkbook::openFromFile(const std::string& path) {
|
|
|
90
37
|
}
|
|
91
38
|
|
|
92
39
|
void HybridXlsxWorkbook::openFromBuffer(const uint8_t* data, size_t size) {
|
|
93
|
-
std::string tempPath =
|
|
40
|
+
std::string tempPath = tempFilePath("xlsx_open");
|
|
94
41
|
std::ofstream file(tempPath, std::ios::binary);
|
|
95
42
|
file.write(reinterpret_cast<const char*>(data), size);
|
|
96
43
|
file.close();
|
|
@@ -103,7 +50,7 @@ void HybridXlsxWorkbook::openFromBuffer(const uint8_t* data, size_t size) {
|
|
|
103
50
|
void HybridXlsxWorkbook::loadWorksheets() {
|
|
104
51
|
_worksheets.clear();
|
|
105
52
|
_worksheetNames.clear();
|
|
106
|
-
|
|
53
|
+
|
|
107
54
|
auto wb = _workbook->workbook();
|
|
108
55
|
auto count = wb.worksheetCount();
|
|
109
56
|
for (uint16_t i = 1; i <= count; ++i) {
|
|
@@ -115,63 +62,149 @@ void HybridXlsxWorkbook::loadWorksheets() {
|
|
|
115
62
|
}
|
|
116
63
|
}
|
|
117
64
|
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
65
|
+
void HybridXlsxWorkbook::ensureOpen() {
|
|
66
|
+
if (_workbook->isOpen()) return;
|
|
67
|
+
std::string tempPath = tempFilePath("xlsx_create");
|
|
68
|
+
_workbook->create(tempPath, OpenXLSX::XLForceOverwrite);
|
|
69
|
+
std::remove(tempPath.c_str());
|
|
70
|
+
loadWorksheets();
|
|
71
|
+
}
|
|
125
72
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
73
|
+
std::shared_ptr<HybridXlsxWorksheetSpec> HybridXlsxWorkbook::addWorksheet(const std::optional<std::string>& name) {
|
|
74
|
+
return withXlsxError(xlsx_error::XLSX_ERROR, [&]() -> std::shared_ptr<HybridXlsxWorksheetSpec> {
|
|
75
|
+
ensureOpen();
|
|
76
|
+
|
|
77
|
+
std::string sheetName;
|
|
78
|
+
if (name.has_value()) {
|
|
79
|
+
sheetName = *name;
|
|
80
|
+
auto it = _worksheetNames.find(sheetName);
|
|
81
|
+
if (it != _worksheetNames.end()) {
|
|
82
|
+
// Worksheet already exists (e.g., default Sheet1 created by OpenXLSX), return it
|
|
83
|
+
return it->second;
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
int idx = 1;
|
|
87
|
+
do {
|
|
88
|
+
sheetName = "Sheet" + std::to_string(idx++);
|
|
89
|
+
} while (_worksheetNames.count(sheetName) > 0);
|
|
133
90
|
}
|
|
134
|
-
} else {
|
|
135
|
-
int idx = 1;
|
|
136
|
-
do {
|
|
137
|
-
sheetName = "Sheet" + std::to_string(idx++);
|
|
138
|
-
} while (_worksheetNames.count(sheetName) > 0);
|
|
139
|
-
}
|
|
140
91
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
92
|
+
_workbook->workbook().addWorksheet(sheetName);
|
|
93
|
+
auto worksheet = _workbook->workbook().worksheet(sheetName);
|
|
94
|
+
auto hybridWorksheet = std::make_shared<HybridXlsxWorksheet>(*_workbook, worksheet);
|
|
95
|
+
_worksheets.push_back(hybridWorksheet);
|
|
96
|
+
_worksheetNames[sheetName] = hybridWorksheet;
|
|
97
|
+
return hybridWorksheet;
|
|
98
|
+
});
|
|
147
99
|
}
|
|
148
100
|
|
|
149
101
|
std::shared_ptr<HybridXlsxWorksheetSpec> HybridXlsxWorkbook::getWorksheet(double index) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
102
|
+
return withXlsxError(xlsx_error::INDEX_OUT_OF_RANGE, [&]() -> std::shared_ptr<HybridXlsxWorksheetSpec> {
|
|
103
|
+
ensureOpen();
|
|
104
|
+
size_t idx = static_cast<size_t>(index);
|
|
105
|
+
if (idx >= _worksheets.size()) {
|
|
106
|
+
throw XlsxError(xlsx_error::INDEX_OUT_OF_RANGE, "Worksheet index out of range: " + std::to_string(idx));
|
|
107
|
+
}
|
|
108
|
+
return _worksheets[idx];
|
|
109
|
+
});
|
|
155
110
|
}
|
|
156
111
|
|
|
157
112
|
std::shared_ptr<HybridXlsxWorksheetSpec> HybridXlsxWorkbook::getWorksheetByName(const std::string& name) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
113
|
+
return withXlsxError(xlsx_error::SHEET_NOT_FOUND, [&]() -> std::shared_ptr<HybridXlsxWorksheetSpec> {
|
|
114
|
+
ensureOpen();
|
|
115
|
+
auto it = _worksheetNames.find(name);
|
|
116
|
+
if (it == _worksheetNames.end()) {
|
|
117
|
+
throw XlsxError(xlsx_error::SHEET_NOT_FOUND, "Worksheet not found: " + name);
|
|
118
|
+
}
|
|
119
|
+
return it->second;
|
|
120
|
+
});
|
|
163
121
|
}
|
|
164
122
|
|
|
165
123
|
std::shared_ptr<HybridXlsxWorksheetSpec> HybridXlsxWorkbook::getOrAddWorksheet(const std::string& name) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
124
|
+
return withXlsxError(xlsx_error::XLSX_ERROR, [&]() -> std::shared_ptr<HybridXlsxWorksheetSpec> {
|
|
125
|
+
ensureOpen();
|
|
126
|
+
auto it = _worksheetNames.find(name);
|
|
127
|
+
if (it != _worksheetNames.end()) {
|
|
128
|
+
return it->second;
|
|
129
|
+
}
|
|
130
|
+
return addWorksheet(name);
|
|
131
|
+
});
|
|
171
132
|
}
|
|
172
133
|
|
|
173
134
|
double HybridXlsxWorkbook::getWorksheetCount() {
|
|
174
|
-
return
|
|
135
|
+
return withXlsxError(xlsx_error::XLSX_ERROR, [&] {
|
|
136
|
+
return static_cast<double>(_workbook->workbook().worksheetCount());
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
void HybridXlsxWorkbook::deleteSheet(const std::string& name) {
|
|
141
|
+
withXlsxError(xlsx_error::XLSX_ERROR, [&] {
|
|
142
|
+
ensureOpen();
|
|
143
|
+
auto it = _worksheetNames.find(name);
|
|
144
|
+
if (it == _worksheetNames.end()) {
|
|
145
|
+
throw XlsxError(xlsx_error::SHEET_NOT_FOUND, "Worksheet not found: " + name);
|
|
146
|
+
}
|
|
147
|
+
if (_worksheetNames.size() <= 1) {
|
|
148
|
+
throw XlsxError(xlsx_error::INVALID_ARGUMENT, "Cannot delete the last worksheet in a workbook");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_workbook->workbook().deleteSheet(name);
|
|
152
|
+
|
|
153
|
+
// Drop the cached hybrid wrappers for the deleted sheet
|
|
154
|
+
for (auto wit = _worksheets.begin(); wit != _worksheets.end(); ++wit) {
|
|
155
|
+
if (*wit == it->second) {
|
|
156
|
+
_worksheets.erase(wit);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
_worksheetNames.erase(it);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
void HybridXlsxWorkbook::updateSheetName(const std::string& oldName, const std::string& newName) {
|
|
165
|
+
withXlsxError(xlsx_error::XLSX_ERROR, [&] {
|
|
166
|
+
ensureOpen();
|
|
167
|
+
auto it = _worksheetNames.find(oldName);
|
|
168
|
+
if (it == _worksheetNames.end()) {
|
|
169
|
+
throw XlsxError(xlsx_error::SHEET_NOT_FOUND, "Worksheet not found: " + oldName);
|
|
170
|
+
}
|
|
171
|
+
if (_worksheetNames.count(newName) > 0) {
|
|
172
|
+
throw XlsxError(xlsx_error::SHEET_EXISTS, "Worksheet already exists: " + newName);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Rename the sheet itself
|
|
176
|
+
it->second->applyRename(oldName, newName);
|
|
177
|
+
|
|
178
|
+
// Rewrite formula references on every worksheet (formulas in other sheets may reference oldName)
|
|
179
|
+
for (auto& [name, hybrid] : _worksheetNames) {
|
|
180
|
+
if (name == oldName) continue;
|
|
181
|
+
hybrid->rewriteSheetNameRef(oldName, newName);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Refresh the name map
|
|
185
|
+
auto hybrid = it->second;
|
|
186
|
+
_worksheetNames.erase(it);
|
|
187
|
+
_worksheetNames[newName] = hybrid;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
std::shared_ptr<HybridXlsxWorksheetSpec> HybridXlsxWorkbook::clone(const std::string& existingName, const std::string& newName) {
|
|
192
|
+
return withXlsxError(xlsx_error::XLSX_ERROR, [&]() -> std::shared_ptr<HybridXlsxWorksheetSpec> {
|
|
193
|
+
ensureOpen();
|
|
194
|
+
if (_worksheetNames.count(existingName) == 0) {
|
|
195
|
+
throw XlsxError(xlsx_error::SHEET_NOT_FOUND, "Worksheet not found: " + existingName);
|
|
196
|
+
}
|
|
197
|
+
if (_worksheetNames.count(newName) > 0) {
|
|
198
|
+
throw XlsxError(xlsx_error::SHEET_EXISTS, "Worksheet already exists: " + newName);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
_workbook->workbook().cloneSheet(existingName, newName);
|
|
202
|
+
auto worksheet = _workbook->workbook().worksheet(newName);
|
|
203
|
+
auto hybridWorksheet = std::make_shared<HybridXlsxWorksheet>(*_workbook, worksheet);
|
|
204
|
+
_worksheets.push_back(hybridWorksheet);
|
|
205
|
+
_worksheetNames[newName] = hybridWorksheet;
|
|
206
|
+
return hybridWorksheet;
|
|
207
|
+
});
|
|
175
208
|
}
|
|
176
209
|
|
|
177
210
|
std::shared_ptr<HybridXlsxCellFormatSpec> HybridXlsxWorkbook::addCellFormat() {
|
|
@@ -184,118 +217,48 @@ std::shared_ptr<Promise<std::shared_ptr<ArrayBuffer>>> HybridXlsxWorkbook::getBu
|
|
|
184
217
|
auto promise = Promise<std::shared_ptr<ArrayBuffer>>::create();
|
|
185
218
|
|
|
186
219
|
if (_finalized) {
|
|
187
|
-
promise->reject(std::make_exception_ptr(
|
|
220
|
+
promise->reject(std::make_exception_ptr(XlsxError(xlsx_error::WORKBOOK_CLOSED, "Workbook has already been finalized")));
|
|
188
221
|
return promise;
|
|
189
222
|
}
|
|
190
223
|
|
|
191
224
|
try {
|
|
192
|
-
std::string tempPath =
|
|
225
|
+
std::string tempPath = tempFilePath("xlsx_temp");
|
|
193
226
|
_workbook->saveAs(tempPath, OpenXLSX::XLForceOverwrite);
|
|
194
|
-
|
|
227
|
+
|
|
195
228
|
std::ifstream file(tempPath, std::ios::binary | std::ios::ate);
|
|
196
229
|
if (!file.is_open()) {
|
|
197
|
-
promise->reject(std::make_exception_ptr(
|
|
230
|
+
promise->reject(std::make_exception_ptr(XlsxError(xlsx_error::IO_ERROR, "Failed to open temp file")));
|
|
198
231
|
return promise;
|
|
199
232
|
}
|
|
200
|
-
|
|
233
|
+
|
|
201
234
|
std::streampos size = file.tellg();
|
|
202
235
|
std::vector<uint8_t> buffer(size);
|
|
203
236
|
file.seekg(0, std::ios::beg);
|
|
204
237
|
file.read(reinterpret_cast<char*>(buffer.data()), size);
|
|
205
238
|
file.close();
|
|
206
|
-
|
|
239
|
+
|
|
207
240
|
std::remove(tempPath.c_str());
|
|
208
|
-
|
|
241
|
+
|
|
209
242
|
auto arrayBuffer = ArrayBuffer::copy(buffer.data(), buffer.size());
|
|
210
243
|
_finalized = true;
|
|
211
|
-
|
|
244
|
+
|
|
212
245
|
promise->resolve(arrayBuffer);
|
|
213
|
-
} catch (const
|
|
246
|
+
} catch (const XlsxError& e) {
|
|
214
247
|
promise->reject(std::make_exception_ptr(e));
|
|
248
|
+
} catch (const OpenXLSX::XLException& e) {
|
|
249
|
+
promise->reject(std::make_exception_ptr(XlsxError(xlsx_error::XLSX_ERROR, e.what())));
|
|
250
|
+
} catch (const std::exception& e) {
|
|
251
|
+
promise->reject(std::make_exception_ptr(XlsxError(xlsx_error::INTERNAL_ERROR, e.what())));
|
|
215
252
|
}
|
|
216
|
-
|
|
253
|
+
|
|
217
254
|
return promise;
|
|
218
255
|
}
|
|
219
256
|
|
|
220
|
-
std::string
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
auto lastRow = static_cast<unsigned int>(ws->getLastRow());
|
|
226
|
-
auto lastCol = static_cast<unsigned int>(ws->getLastColumn());
|
|
227
|
-
if (lastRow == 0 || lastCol == 0) {
|
|
228
|
-
return "[]";
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
unsigned int dataStartRow = 1;
|
|
232
|
-
std::vector<std::string> resolvedKeys;
|
|
233
|
-
|
|
234
|
-
if (keys.has_value()) {
|
|
235
|
-
resolvedKeys = *keys;
|
|
236
|
-
} else {
|
|
237
|
-
dataStartRow = 2;
|
|
238
|
-
for (unsigned int c = 1; c <= lastCol; ++c) {
|
|
239
|
-
auto val = ws->getCellValue(1, c);
|
|
240
|
-
if (auto* s = std::get_if<std::string>(&val)) {
|
|
241
|
-
resolvedKeys.push_back(*s);
|
|
242
|
-
} else if (auto* d = std::get_if<double>(&val)) {
|
|
243
|
-
resolvedKeys.push_back(std::to_string(static_cast<int>(*d)));
|
|
244
|
-
} else {
|
|
245
|
-
resolvedKeys.push_back("col" + std::to_string(c));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (resolvedKeys.empty()) {
|
|
251
|
-
return "[]";
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
std::ostringstream out;
|
|
255
|
-
out << "[";
|
|
256
|
-
|
|
257
|
-
bool firstRow = true;
|
|
258
|
-
|
|
259
|
-
for (unsigned int r = dataStartRow; r <= lastRow; ++r) {
|
|
260
|
-
bool hasData = false;
|
|
261
|
-
for (unsigned int c = 1; c <= std::min(static_cast<unsigned int>(resolvedKeys.size()), lastCol); ++c) {
|
|
262
|
-
auto cellType = ws->getCellType(r, c);
|
|
263
|
-
if (cellType != CellType::EMPTY) {
|
|
264
|
-
hasData = true;
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (!hasData) continue;
|
|
269
|
-
|
|
270
|
-
if (!firstRow) out << ",";
|
|
271
|
-
firstRow = false;
|
|
272
|
-
|
|
273
|
-
out << "{";
|
|
274
|
-
unsigned int keyCount = std::min(static_cast<unsigned int>(resolvedKeys.size()), lastCol);
|
|
275
|
-
for (unsigned int c = 0; c < keyCount; ++c) {
|
|
276
|
-
if (c > 0) out << ",";
|
|
277
|
-
writeJsonString(out, resolvedKeys[c]);
|
|
278
|
-
out << ":";
|
|
279
|
-
auto val = ws->getCellValue(r, c + 1);
|
|
280
|
-
if (auto* s = std::get_if<std::string>(&val)) {
|
|
281
|
-
writeJsonString(out, *s);
|
|
282
|
-
} else if (auto* d = std::get_if<double>(&val)) {
|
|
283
|
-
if (std::isnan(*d) || std::isinf(*d)) {
|
|
284
|
-
out << "null";
|
|
285
|
-
} else {
|
|
286
|
-
out << *d;
|
|
287
|
-
}
|
|
288
|
-
} else if (auto* b = std::get_if<bool>(&val)) {
|
|
289
|
-
out << (*b ? "true" : "false");
|
|
290
|
-
} else {
|
|
291
|
-
out << "null";
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
out << "}";
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
out << "]";
|
|
298
|
-
return out.str();
|
|
257
|
+
std::unordered_map<std::string, std::vector<std::shared_ptr<AnyMap>>> HybridXlsxWorkbook::toJSON() {
|
|
258
|
+
return withXlsxError(xlsx_error::XLSX_ERROR, [&] {
|
|
259
|
+
auto wb = _workbook->workbook();
|
|
260
|
+
return workbookToRecords(wb);
|
|
261
|
+
});
|
|
299
262
|
}
|
|
300
263
|
|
|
301
264
|
}
|
|
@@ -13,7 +13,7 @@ namespace margelo::nitro::xlsx {
|
|
|
13
13
|
|
|
14
14
|
class HybridXlsxWorkbook : public HybridXlsxWorkbookSpec {
|
|
15
15
|
public:
|
|
16
|
-
HybridXlsxWorkbook(
|
|
16
|
+
HybridXlsxWorkbook();
|
|
17
17
|
~HybridXlsxWorkbook() override;
|
|
18
18
|
|
|
19
19
|
void openFromFile(const std::string& path);
|
|
@@ -24,9 +24,12 @@ public:
|
|
|
24
24
|
std::shared_ptr<HybridXlsxWorksheetSpec> getWorksheetByName(const std::string& name) override;
|
|
25
25
|
std::shared_ptr<HybridXlsxWorksheetSpec> getOrAddWorksheet(const std::string& name) override;
|
|
26
26
|
double getWorksheetCount() override;
|
|
27
|
+
void deleteSheet(const std::string& name) override;
|
|
28
|
+
void updateSheetName(const std::string& oldName, const std::string& newName) override;
|
|
29
|
+
std::shared_ptr<HybridXlsxWorksheetSpec> clone(const std::string& existingName, const std::string& newName) override;
|
|
27
30
|
std::shared_ptr<HybridXlsxCellFormatSpec> addCellFormat() override;
|
|
28
31
|
std::shared_ptr<Promise<std::shared_ptr<ArrayBuffer>>> getBuffer() override;
|
|
29
|
-
std::string
|
|
32
|
+
std::unordered_map<std::string, std::vector<std::shared_ptr<AnyMap>>> toJSON() override;
|
|
30
33
|
|
|
31
34
|
private:
|
|
32
35
|
std::unique_ptr<OpenXLSX::XLDocument> _workbook;
|
|
@@ -37,6 +40,8 @@ private:
|
|
|
37
40
|
std::string _tempDir;
|
|
38
41
|
|
|
39
42
|
void loadWorksheets();
|
|
43
|
+
void ensureOpen();
|
|
44
|
+
std::string tempFilePath(const char* prefix);
|
|
40
45
|
};
|
|
41
46
|
|
|
42
47
|
}
|