在写STM32程序时候,一些复杂计算通常不会放到单片机里面计算,而是先用excel表格进行计算出结果,然后将结果放到程序数组中,通过查表来实现计算,这个小工具是为了实现excel转C语言数组格式,方便将excel表数据写入代码中.
@echo off
::输入文件名
set "input_file=excel_input.txt"
::输出文件名
set "output_file=excel_output.txt"
::每行个数
set /a num_of_rows = 8
::必须设置这个
setlocal enabledelayedexpansion
echo Delete expired files....
del !output_file! >nul
echo Files in progress....
set n=1
for /f "tokens=*" %%i in (!input_file!) do (
set /p str = %%i,<nul>>!output_file!
set /a n += 1
if !n! GTR !num_of_rows! (
echo. >>!output_file!
set /a n = 1
)
)
echo progress OK!
pause
使用方法:
新建一个1.bat文件复制上面的代码,然后粘贴到1.bat文件中,保存退出
然后新建一个文本文件名为excel_input.txt,将excel表格的内容复制到文本
双击1.bat运行
看到OK说明执行成功,同时会出现一个excel_output.txt文件,里面就是换行过后的数据
这样就不用手动的一行行敲回车
不想这么麻烦的可以直接下载脚本文件使用
https://download.csdn.net/download/xxdx_admin/86398224