![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-03 11:59 |
48,038 topics / 350,123 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » How to directly convert a TXT file to an XLS file using batch processing |
| Printable Version 4,913 / 16 |
| Floor1 xycoordinate | Posted 2007-02-24 00:29 |
| 中级用户 Posts 228 Credits 493 From 安徽 | |
|
How to directly convert a TXT file to an XLS file using batch processing
report.txt
[ Last edited by xycoordinate on 2007-2-23 at 11:34 AM ] |
|
| Floor2 slore | Posted 2007-02-24 00:47 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
xls
What format do you see when you open it with Notepad? |
|
| Floor3 anqing | Posted 2007-02-24 01:32 |
| 高级用户 Posts 413 Credits 859 | |
|
Can the numbers in the txt be accurately given to the xls file?
|
|
| Floor4 slore | Posted 2007-02-24 01:34 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
Of course, if the format is regular.
|
|
| Floor5 zh159 | Posted 2007-02-24 01:34 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
Now there's no time to write code. Here's an idea:
First, replace double spaces with single spaces, then replace single spaces with {TAB} + single space ({TAB}: tab character) Then directly open the TXT file with Excel |
|
| Floor6 slore | Posted 2007-02-24 01:53 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
After looking at the original existing xls document, it seems not in plain text form...
Then it's the simulated input on the 5th floor... |
|
| Floor7 slore | Posted 2007-02-24 02:40 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
The script can reference this object Excel.Application
|
|
| Floor8 vkill | Posted 2007-02-24 02:50 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
This shouldn't be possible. An XLS file is garbled when opened with Notepad.
|
|
| Floor9 amao | Posted 2007-02-24 03:20 |
| 中级用户 Posts 152 Credits 316 | |
|
sed "s/^*//;s/\+/\t/g" report.txt> result.xls
For downloading and using sed, please search the forum with "sed" [ Last edited by amao on 2007-2-24 at 03:22 AM ] |
|
| Floor10 NaturalJ0 | Posted 2007-02-24 03:27 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
If separated by spaces, tabs, or commas, you can directly open the TXT file with EXCEL, and EXCEL will ask you how to separate.
PS: Tabs are well separated. Copy to the clipboard, then open EXCEL and paste. If so, you need to use VBS. |
|
| Floor11 zh159 | Posted 2007-02-24 03:56 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
The generated "test.xls" can be directly opened with Excel
{TAB}: Keyboard TAB tab PS: Is there a problem with the last line of your data "14 321 1702 29 171650 ", missing the third data? [ Last edited by zh159 on 2007-2-23 at 06:16 PM ] |
|
| Floor12 xycoordinate | Posted 2007-02-24 09:38 |
| 中级用户 Posts 228 Credits 493 From 安徽 | |
Originally posted by zh159 at 2007-2-23 02:56 PM: Thank you!!! NNNNNN!!!!!!!!!!!!! Also:
The meaning is not very clear??? Is it this? set /? I can directly use tab to separate columns and it's OK!!!! The 20070131.txt has the following format, directly changing the extension to xls will be as I wish!!! 1 13 45 0 4500 15615 2 13 45 0 4500 15600 3 26 255 0 25500 15601 4 18 81 0 8100 15602 5 29 188 0 18800 15605 6 25 150 0 15000 15606 7 84 333 12 33900 15609 8 20 105 1 10550 15610 9 26 128 0 12800 15611 10 14 149 0 14900 15612 11 5 33 0 3300 15613 12 0 0 0 0 15616 13 48 190 16 19800 15617 14 321 1702 29 171650 [ Last edited by xycoordinate on 2007-2-23 at 10:53 PM ] |
|
| Floor13 vkill | Posted 2007-02-24 09:39 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
| Floor14 chainliq | Posted 2007-02-24 10:46 |
| 高级用户 Posts 244 Credits 635 From 广西贵港 | |
|
Hehe, this is also simple`````
@echo off type report.txt echo >>report.xls |
|
| Floor15 xycoordinate | Posted 2007-02-24 11:43 |
| 中级用户 Posts 228 Credits 493 From 安徽 | |
Originally posted by chainliq at 2007-2-23 09:46 PM: ![]()
Why does it report an error????? The report.xls is indeed generated, but the format is incorrect!!! |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |