This commit is contained in:
2025-11-06 11:12:21 +08:00
parent 7860df5c2e
commit a7f581bdbe
5 changed files with 474 additions and 23 deletions

View File

@@ -509,11 +509,10 @@ public class TencentDocController extends BaseController {
fileId, sheetId, startRow, endRow, lastMaxRow);
// 读取表格数据(先读取表头行用于识别列位置)
// 腾讯文档V3 API的range格式startRow,startColumn,endRow,endColumn从0开始的索引
// 例如第2行A列到Z列 = "1,0,1,25"行索引从0开始所以第2行是索引1
int headerRowIndex = headerRow - 1; // Excel行号转索引第2行 = 索引1
String headerRange = String.format("%d,0,%d,25", headerRowIndex, headerRowIndex); // 读取A到Z列0-25
log.info("读取表头 - Excel行号: {}, 索引行号: {}, range: {}", headerRow, headerRowIndex, headerRange);
// 根据官方文档,使用 A1 表示法Excel格式
// 参考https://docs.qq.com/open/document/app/openapi/v3/sheet/get/get_range.html
String headerRange = String.format("A%d:Z%d", headerRow, headerRow); // 例如A2:Z2
log.info("读取表头 - 行号: {}, range: {}", headerRow, headerRange);
JSONObject headerData = null;
try {
@@ -566,11 +565,9 @@ public class TencentDocController extends BaseController {
}
// 读取数据行
// 构建数据行的range从startRow到endRowA列到Z列
int startRowIndex = startRow - 1; // Excel行号转索引
int endRowIndex = endRow - 1; // Excel行号转索引
String range = String.format("%d,0,%d,25", startRowIndex, endRowIndex); // 读取A到Z列0-25
log.info("开始读取数据行 - Excel行号: {} ~ {}, 索引: {} ~ {}, range: {}", startRow, endRow, startRowIndex, endRowIndex, range);
// 使用 A1 表示法Excel格式
String range = String.format("A%d:Z%d", startRow, endRow); // 例如A3:Z203
log.info("开始读取数据行 - 行号: {} ~ {}, range: {}", startRow, endRow, range);
JSONObject sheetData = null;
try {