init:初版可用
This commit is contained in:
commit
79085484b0
17
.clang-format
Normal file
17
.clang-format
Normal file
@ -0,0 +1,17 @@
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
PointerAlignment: Left
|
||||
AccessModifierOffset: -4
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterFunction: true
|
||||
AfterClass: true
|
||||
Cpp11BracedListStyle: true
|
||||
ReflowComments: true
|
||||
SpacesBeforeTrailingComments: 3
|
||||
TabWidth: 4
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ColumnLimit: 80
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortEnumsOnASingleLine: false
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
build
|
||||
.vs
|
||||
.cache
|
||||
cmake-*
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "ofen"]
|
||||
path = ofen
|
||||
url = https://www.sinxmiao.cn/taynpg/ofen
|
110
.vscode/settings.json
vendored
Normal file
110
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
{
|
||||
"files.autoSave": "onFocusChange",
|
||||
"editor.fontSize": 14,
|
||||
"editor.fontFamily": "'Source Code Pro', 'Courier New', monospace",
|
||||
"terminal.integrated.fontFamily": "Source Code Pro",
|
||||
"cmake.configureOnOpen": true,
|
||||
"cmake.debugConfig": {
|
||||
"console": "integratedTerminal",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "-gdb-set charset utf-8",
|
||||
"text": "-gdb-set charset UTF-8"
|
||||
},
|
||||
{
|
||||
"description": "Enable gdb pretty-printing",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
"cmake.configureSettings": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
},
|
||||
"cmake.options.statusBarVisibility": "visible",
|
||||
"cmake.generator": "Ninja",
|
||||
"C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json",
|
||||
"C_Cpp.default.cppStandard": "c++17",
|
||||
"editor.inlayHints.enabled": "off",
|
||||
"editor.unicodeHighlight.allowedLocales": {
|
||||
"ja": true,
|
||||
"zh-hant": true,
|
||||
"zh-hans": true
|
||||
},
|
||||
"files.associations": {
|
||||
"vector": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"cctype": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"deque": "cpp",
|
||||
"exception": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"format": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"fstream": "cpp",
|
||||
"functional": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"ios": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"iterator": "cpp",
|
||||
"limits": "cpp",
|
||||
"list": "cpp",
|
||||
"locale": "cpp",
|
||||
"map": "cpp",
|
||||
"memory": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"queue": "cpp",
|
||||
"ratio": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string": "cpp",
|
||||
"system_error": "cpp",
|
||||
"thread": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"utility": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xstring": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp"
|
||||
}
|
||||
}
|
27
CMakeLists.txt
Normal file
27
CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(rbs_tool LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/source-charset:utf-8)
|
||||
endif()
|
||||
|
||||
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "Compiler CXX ID: ${CMAKE_CXX_COMPILER_ID}")
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/)
|
||||
|
||||
if (MSVC)
|
||||
find_package(Xlnt CONFIG REQUIRED)
|
||||
endif()
|
||||
|
||||
add_subdirectory(ofen)
|
||||
add_executable(rbs_tool main.cpp)
|
||||
target_link_libraries(rbs_tool PRIVATE ofen)
|
||||
if (MSVC)
|
||||
target_link_libraries(rbs_tool PRIVATE xlnt::xlnt)
|
||||
else()
|
||||
target_link_libraries(rbs_tool PRIVATE xlnt)
|
||||
endif()
|
5
REAME.md
Normal file
5
REAME.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 简介
|
||||
|
||||
命令行第二个参数,输入一个`xlsx`文件,输出在程序所在目录下。
|
||||
|
||||
当前程序默认操作第一张表。
|
60
main.cpp
Normal file
60
main.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <of_path.h>
|
||||
#include <of_util.h>
|
||||
#include <of_str.h>
|
||||
#include <xlnt/xlnt.hpp>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
std::cout << "Second arg is xlsx file path." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::string input_file(argv[1]);
|
||||
std::string full_path = ofen::COfPath::to_full(input_file);
|
||||
std::cout << "Load File:" << full_path << std::endl;
|
||||
|
||||
if (!fs::exists(full_path)) {
|
||||
std::cerr << "File not found." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string file_name = fs::path(full_path).filename().string();
|
||||
std::string out_file_name = ofen::COfStr::get_ofile_name(file_name);
|
||||
try {
|
||||
xlnt::workbook wb;
|
||||
wb.load(full_path);
|
||||
xlnt::workbook wb_out;
|
||||
xlnt::worksheet ws_out = wb_out.active_sheet();
|
||||
|
||||
std::cout << "Sheets in the workbook:" << std::endl;
|
||||
for (const auto& sheet_name : wb.sheet_titles()) {
|
||||
std::cout << " - " << sheet_name << std::endl;
|
||||
}
|
||||
std::string sheet_name = wb.sheet_titles().front();
|
||||
xlnt::worksheet ws = wb.sheet_by_title(sheet_name);
|
||||
|
||||
auto rows = ws.highest_row();
|
||||
auto columns = ws.highest_column().index;
|
||||
std::cout << "Sheet: " << sheet_name << " has " << rows << " rows and "
|
||||
<< columns << " columns." << std::endl;
|
||||
|
||||
for (std::uint32_t i = 0; i < rows; ++i) {
|
||||
for (std::uint32_t j = 0; j < columns; ++j) {
|
||||
auto cell = ws.cell(j + 1, i + 1);
|
||||
if (cell.has_value()) {
|
||||
std::string cur = cell.to_string();
|
||||
auto ret = ofen::CCodec::rbs(cur);
|
||||
ws_out.cell(j + 1, i + 1).value(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
wb_out.save(out_file_name);
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
}
|
||||
std::cout << "Done" << std::endl;
|
||||
return 0;
|
||||
}
|
1
ofen
Submodule
1
ofen
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 2be0e9631729cf85e79b23fb921209182e0907be
|
Loading…
x
Reference in New Issue
Block a user