Skip to content

Commit 17e2498

Browse files
committed
add force_text_value option in md_to_xlsx tool to control whether to force convert all cell values to text string
1 parent 985de92 commit 17e2498

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ Output `.md` file with orginal input Markdown text.
339339
- [ BREAKING CHANGE ] migrate to `pandoc` for conversion in the following tools:
340340
- `md_to_docx`
341341
- remove `md_to_rst` and `md_to_epub` tools
342+
- add `force_text_value` option in md_to_xlsx tool to control whether to force convert all cell values to text string
342343

343344
- 1.12.0:
344345
- fix input pptx template file optional in `md_to_pptx` tool

tools/md_to_xlsx/md_to_xlsx.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from tools.utils.file_utils import get_meta_data
1010
from tools.utils.logger_utils import get_logger
1111
from tools.utils.mimetype_utils import MimeType
12-
from tools.utils.param_utils import get_md_text
12+
from tools.utils.param_utils import get_md_text, get_param_value
1313
from tools.utils.table_utils import TableParser, SUGGESTED_SHEET_NAME
1414

1515

@@ -23,9 +23,10 @@ def _invoke(self, tool_parameters: dict) -> Generator[ToolInvokeMessage, None, N
2323

2424
# get parameters
2525
md_text = get_md_text(tool_parameters)
26+
force_text_value: bool = ("true" == get_param_value(tool_parameters, "force_text_value", "true").lower())
2627

2728
# parse markdown to tables
28-
tables = TableParser.parse_md_to_tables(self.logger, md_text)
29+
tables = TableParser.parse_md_to_tables(self.logger, md_text=md_text, force_value_to_str=force_text_value)
2930

3031
# generate XLSX file
3132
try:

tools/md_to_xlsx/md_to_xlsx.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@ parameters:
2020
en_US: "Input text of single or multiple Markdown tables, with worksheets supported. All the heading texts (eg. #, ##) will be used as worksheet names in order."
2121
zh_Hans: "单个或多个 Markdown 表格的文本输入,支持工作表。所有标题文本(例如 #, ##)将依次用作工作表名称。"
2222
form: llm
23+
- name: force_text_value
24+
type: select
25+
required: true
26+
default: "true"
27+
options:
28+
- value: "true"
29+
label:
30+
en_US: "Yes"
31+
zh_Hans:
32+
- value: "false"
33+
label:
34+
en_US: "No"
35+
zh_Hans:
36+
label:
37+
en_US: Enforce text type
38+
zh_Hans: 强制单元格值为文本类型
39+
human_description:
40+
en_US: Convert cell values into text type to void decimal precision loss in display
41+
zh_Hans: 转换单元格值为文本类型,避免显示时的小数精度丢失
42+
llm_description: Whether to convert cell values into string type, default to "true"
43+
form: form
2344
- name: output_filename
2445
type: string
2546
required: false

0 commit comments

Comments
 (0)