首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

xlnt_demo,利用C++开源库xlnt读写excel,vs2015工程

后端 3.21MB 69 需要积分: 1
立即下载

资源介绍:

利用C++开源库xlnt读写excel的vs2015工程。详细教程参考博客:https://humfrey.blog.csdn.net/article/details/107527883
#include #include #include #include void read_to_screen(std::string filepath) { xlnt::workbook wb; wb.load(filepath); auto ws = wb.active_sheet(); std::clog << "Processing spread sheet" << std::endl; // 会把当前占用的单元格全都打印出来,空单元格则为空格。 for (auto row : ws.rows(false)) { for (auto cell : row) { std::clog << cell.to_string() << "\t"; } std::clog << std::endl; } std::clog << "Processing complete" << std::endl; } std::vector< std::vector > read_to_vector(std::string filepath) { xlnt::workbook wb; wb.load(filepath); auto ws = wb.active_sheet(); 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)) { std::vector aSingleRow; for (auto cell : row) { aSingleRow.push_back(cell.to_string()); } theWholeSpreadSheet.push_back(aSingleRow); } std::clog << "Processing complete" << std::endl << 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++) { std::cout << theWholeSpreadSheet.at(rowInt).at(colInt) << "\t"; } std::cout << std::endl; } return theWholeSpreadSheet; } void save_demo(std::string filepath) { xlnt::workbook wb; xlnt::worksheet ws = wb.active_sheet(); //赋值为数值 ws.cell("A1").value(0.5); //设置单位格格式,设为百分比形式 ws.cell("A1").number_format(xlnt::number_format::percentage()); //赋值为字符串 ws.cell("B2").value("string data"); //赋值为公式 ws.cell("C3").formula("=RAND()"); //合并单元格 ws.merge_cells("C3:C4"); //冻结窗格 ws.freeze_panes("B2"); //保存 wb.save(filepath); } void save_from_vector(std::string filepath) { std::vector< std::vector > wholeWorksheet; for (int outer = 0; outer < 10; outer++) { std::vector singleRow; for (int inner = 0; inner < 10; inner++) { //给vector中的每个元素赋值 std::string val = std::to_string(inner + 1); singleRow.push_back(val); } wholeWorksheet.push_back(singleRow); } //创建工作簿 std::clog << "Creating workbook" << std::endl; xlnt::workbook wbOut; //创建工作表,并把vector中的元素写入表格 xlnt::worksheet wsOut = wbOut.active_sheet(); //给工作表设置名称 wsOut.title("data"); std::clog << "Looping through vector and writing to spread sheet" << std::endl; for (int fOut = 0; fOut < wholeWorksheet.size(); fOut++) { std::clog << "Row" << fOut << std::endl; for (int fIn = 0; fIn < wholeWorksheet.at(fOut).size(); fIn++) { // 给单元格赋值 // 特别注意:工作表中的单元格下标是从1开始,而vector中的元素下标是从0开始 wsOut.cell(xlnt::cell_reference(fIn + 1, fOut + 1)).value(wholeWorksheet.at(fOut).at(fIn)); } } std::clog << "Finished writing spread sheet" << std::endl; wbOut.save(filepath); } int main() { //read_to_screen("test_read.xlsx"); //read_to_vector("test_read.xlsx"); //save_demo("test_save.xlsx"); save_from_vector("test_save.xlsx"); getchar(); return 0; }

资源文件列表:

xlnt_demo.zip 大约有122个文件
  1. xlnt_demo/
  2. xlnt_demo/x64/
  3. xlnt_demo/x64/Release/
  4. xlnt_demo/x64/Release/xlnt.dll 1.82MB
  5. xlnt_demo/x64/Release/xlnt_demo.exe 23.5KB
  6. xlnt_demo/x64/Release/xlnt_demo.iobj 609.91KB
  7. xlnt_demo/x64/Release/xlnt_demo.ipdb 198.89KB
  8. xlnt_demo/x64/Release/xlnt_demo.pdb 1.41MB
  9. xlnt_demo/xlnt_demo/
  10. xlnt_demo/xlnt_demo/bin/
  11. xlnt_demo/xlnt_demo/bin/xlnt.dll 1.82MB
  12. xlnt_demo/xlnt_demo/include/
  13. xlnt_demo/xlnt_demo/include/xlnt/
  14. xlnt_demo/xlnt_demo/include/xlnt/cell/
  15. xlnt_demo/xlnt_demo/include/xlnt/cell/cell.hpp 21.06KB
  16. xlnt_demo/xlnt_demo/include/xlnt/cell/cell_reference.hpp 9.62KB
  17. xlnt_demo/xlnt_demo/include/xlnt/cell/cell_type.hpp 2.04KB
  18. xlnt_demo/xlnt_demo/include/xlnt/cell/comment.hpp 4.7KB
  19. xlnt_demo/xlnt_demo/include/xlnt/cell/hyperlink.hpp 2.2KB
  20. xlnt_demo/xlnt_demo/include/xlnt/cell/index_types.hpp 9.99KB
  21. xlnt_demo/xlnt_demo/include/xlnt/cell/phonetic_run.hpp 1.6KB
  22. xlnt_demo/xlnt_demo/include/xlnt/cell/rich_text.hpp 5.58KB
  23. xlnt_demo/xlnt_demo/include/xlnt/cell/rich_text_run.hpp 1.71KB
  24. xlnt_demo/xlnt_demo/include/xlnt/drawing/
  25. xlnt_demo/xlnt_demo/include/xlnt/drawing/spreadsheet_drawing.hpp 1.89KB
  26. xlnt_demo/xlnt_demo/include/xlnt/packaging/
  27. xlnt_demo/xlnt_demo/include/xlnt/packaging/ext_list.hpp 2.71KB
  28. xlnt_demo/xlnt_demo/include/xlnt/packaging/manifest.hpp 7.56KB
  29. xlnt_demo/xlnt_demo/include/xlnt/packaging/relationship.hpp 5KB
  30. xlnt_demo/xlnt_demo/include/xlnt/packaging/uri.hpp 6.76KB
  31. xlnt_demo/xlnt_demo/include/xlnt/styles/
  32. xlnt_demo/xlnt_demo/include/xlnt/styles/alignment.hpp 4.92KB
  33. xlnt_demo/xlnt_demo/include/xlnt/styles/border.hpp 6.12KB
  34. xlnt_demo/xlnt_demo/include/xlnt/styles/color.hpp 9.7KB
  35. xlnt_demo/xlnt_demo/include/xlnt/styles/conditional_format.hpp 4.33KB
  36. xlnt_demo/xlnt_demo/include/xlnt/styles/fill.hpp 9.93KB
  37. xlnt_demo/xlnt_demo/include/xlnt/styles/font.hpp 8.51KB
  38. xlnt_demo/xlnt_demo/include/xlnt/styles/format.hpp 7.52KB
  39. xlnt_demo/xlnt_demo/include/xlnt/styles/number_format.hpp 7.75KB
  40. xlnt_demo/xlnt_demo/include/xlnt/styles/protection.hpp 3.4KB
  41. xlnt_demo/xlnt_demo/include/xlnt/styles/style.hpp 8.34KB
  42. xlnt_demo/xlnt_demo/include/xlnt/utils/
  43. xlnt_demo/xlnt_demo/include/xlnt/utils/calendar.hpp 1.5KB
  44. xlnt_demo/xlnt_demo/include/xlnt/utils/date.hpp 2.92KB
  45. xlnt_demo/xlnt_demo/include/xlnt/utils/datetime.hpp 4.08KB
  46. xlnt_demo/xlnt_demo/include/xlnt/utils/exceptions.hpp 9.1KB
  47. xlnt_demo/xlnt_demo/include/xlnt/utils/numeric.hpp 6.87KB
  48. xlnt_demo/xlnt_demo/include/xlnt/utils/optional.hpp 10.73KB
  49. xlnt_demo/xlnt_demo/include/xlnt/utils/path.hpp 6.89KB
  50. xlnt_demo/xlnt_demo/include/xlnt/utils/scoped_enum_hash.hpp 1.76KB
  51. xlnt_demo/xlnt_demo/include/xlnt/utils/time.hpp 3.03KB
  52. xlnt_demo/xlnt_demo/include/xlnt/utils/timedelta.hpp 2.55KB
  53. xlnt_demo/xlnt_demo/include/xlnt/utils/variant.hpp 5.12KB
  54. xlnt_demo/xlnt_demo/include/xlnt/workbook/
  55. xlnt_demo/xlnt_demo/include/xlnt/workbook/calculation_properties.hpp 2.06KB
  56. xlnt_demo/xlnt_demo/include/xlnt/workbook/document_security.hpp 3.34KB
  57. xlnt_demo/xlnt_demo/include/xlnt/workbook/external_book.hpp 1.46KB
  58. xlnt_demo/xlnt_demo/include/xlnt/workbook/metadata_property.hpp 2.26KB
  59. xlnt_demo/xlnt_demo/include/xlnt/workbook/named_range.hpp 2.99KB
  60. xlnt_demo/xlnt_demo/include/xlnt/workbook/streaming_workbook_reader.hpp 4.67KB
  61. xlnt_demo/xlnt_demo/include/xlnt/workbook/streaming_workbook_writer.hpp 3.84KB
  62. xlnt_demo/xlnt_demo/include/xlnt/workbook/theme.hpp 1.54KB
  63. xlnt_demo/xlnt_demo/include/xlnt/workbook/workbook.hpp 30.02KB
  64. xlnt_demo/xlnt_demo/include/xlnt/workbook/workbook_view.hpp 3.92KB
  65. xlnt_demo/xlnt_demo/include/xlnt/workbook/worksheet_iterator.hpp 8.73KB
  66. xlnt_demo/xlnt_demo/include/xlnt/worksheet/
  67. xlnt_demo/xlnt_demo/include/xlnt/worksheet/cell_iterator.hpp 9.98KB
  68. xlnt_demo/xlnt_demo/include/xlnt/worksheet/cell_vector.hpp 7.01KB
  69. xlnt_demo/xlnt_demo/include/xlnt/worksheet/column_properties.hpp 2.49KB
  70. xlnt_demo/xlnt_demo/include/xlnt/worksheet/header_footer.hpp 10.49KB
  71. xlnt_demo/xlnt_demo/include/xlnt/worksheet/major_order.hpp 1.46KB
  72. xlnt_demo/xlnt_demo/include/xlnt/worksheet/page_margins.hpp 3.46KB
  73. xlnt_demo/xlnt_demo/include/xlnt/worksheet/page_setup.hpp 5.69KB
  74. xlnt_demo/xlnt_demo/include/xlnt/worksheet/pane.hpp 2.89KB
  75. xlnt_demo/xlnt_demo/include/xlnt/worksheet/phonetic_pr.hpp 4.5KB
  76. xlnt_demo/xlnt_demo/include/xlnt/worksheet/print_options.hpp 2.37KB
  77. xlnt_demo/xlnt_demo/include/xlnt/worksheet/range.hpp 9.74KB
  78. xlnt_demo/xlnt_demo/include/xlnt/worksheet/range_iterator.hpp 8.49KB
  79. xlnt_demo/xlnt_demo/include/xlnt/worksheet/range_reference.hpp 6.4KB
  80. xlnt_demo/xlnt_demo/include/xlnt/worksheet/row_properties.hpp 2.88KB
  81. xlnt_demo/xlnt_demo/include/xlnt/worksheet/selection.hpp 4.61KB
  82. xlnt_demo/xlnt_demo/include/xlnt/worksheet/sheet_format_properties.hpp 2.29KB
  83. xlnt_demo/xlnt_demo/include/xlnt/worksheet/sheet_pr.hpp 3.11KB
  84. xlnt_demo/xlnt_demo/include/xlnt/worksheet/sheet_protection.hpp 2.15KB
  85. xlnt_demo/xlnt_demo/include/xlnt/worksheet/sheet_view.hpp 6.75KB
  86. xlnt_demo/xlnt_demo/include/xlnt/worksheet/worksheet.hpp 26.05KB
  87. xlnt_demo/xlnt_demo/include/xlnt/xlnt.hpp 3.41KB
  88. xlnt_demo/xlnt_demo/include/xlnt/xlnt_config.hpp 1.6KB
  89. xlnt_demo/xlnt_demo/lib/
  90. xlnt_demo/xlnt_demo/lib/cmake/
  91. xlnt_demo/xlnt_demo/lib/cmake/xlnt/
  92. xlnt_demo/xlnt_demo/lib/cmake/xlnt/XlntConfig.cmake 1.15KB
  93. xlnt_demo/xlnt_demo/lib/cmake/xlnt/XlntConfigVersion.cmake 1.84KB
  94. xlnt_demo/xlnt_demo/lib/cmake/xlnt/XlntTargets-release.cmake 866B
  95. xlnt_demo/xlnt_demo/lib/cmake/xlnt/XlntTargets.cmake 3.25KB
  96. xlnt_demo/xlnt_demo/lib/xlnt.lib 615.39KB
  97. xlnt_demo/xlnt_demo/main.cpp 3.28KB
  98. xlnt_demo/xlnt_demo/share/
  99. xlnt_demo/xlnt_demo/share/man/
  100. xlnt_demo/xlnt_demo/share/man/man3/
  101. xlnt_demo/xlnt_demo/share/man/man3/xlnt.3 63.18KB
  102. xlnt_demo/xlnt_demo/test_read.xlsx 8.67KB
  103. xlnt_demo/xlnt_demo/test_save.xlsx 12.84KB
  104. xlnt_demo/xlnt_demo/x64/
  105. xlnt_demo/xlnt_demo/x64/Release/
  106. xlnt_demo/xlnt_demo/x64/Release/main.obj 1.32MB
  107. xlnt_demo/xlnt_demo/x64/Release/vc140.pdb 1.07MB
  108. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.Build.CppClean.log 637B
  109. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.log 449B
  110. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/
  111. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/CL.command.1.tlog 656B
  112. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/CL.read.1.tlog 26.77KB
  113. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/CL.write.1.tlog 354B
  114. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/link.command.1.tlog 1.28KB
  115. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/link.read.1.tlog 3.74KB
  116. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/link.write.1.tlog 588B
  117. xlnt_demo/xlnt_demo/x64/Release/xlnt_demo.tlog/xlnt_demo.lastbuildstate 196B
  118. xlnt_demo/xlnt_demo/xlnt.dll 1.82MB
  119. xlnt_demo/xlnt_demo/xlnt_demo.vcxproj 5.95KB
  120. xlnt_demo/xlnt_demo/xlnt_demo.vcxproj.filters 945B
  121. xlnt_demo/xlnt_demo/xlnt_demo.vcxproj.user 165B
  122. xlnt_demo/xlnt_demo.sln 1.28KB
0评论
提交 加载更多评论
其他资源 openfire3.10.2缺失的jar包(修改版)
找了两三天,得到所有openfire3.10.2缺失jar包,包含7个,导入到工程即可。期间遇到很多问题,比如无法找到HTTPSPDYServerConnector类等,都已经能够解决了。
MSP430F5529的官方例程
本文件是MSP430F5529的官方例程,虽然在官网上可以找到,但是很不好找,里面有十几个实验例程,注意代码是在solution这个文件夹里面
System.Data.SQLite.DLL 64bit
64位运行库 SQLite is a in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
CXF整合Spring需要用到的JAR包
CXF整合Spring需要用到的JAR包
落雪音乐自定义音源切换
落雪音乐自定义音源切换
usbCan(c#实例)
usbcan(c#实例)解决了一次只能接受一条数据的问题
博图MODBUS轮询程序
基于博图1200系列制作的多站轮询减低编程压力,提高编程效率,帮助新手过渡
chropath安装包crx6.1.7下载.zip
获取相对XPath、绝对XPath和CSS选择器。编辑、检查和验证DevTools面板本身中的XPath和CSS选择器。