社区
Java
帖子详情
有没有将TXT转换EXCEl的小程序?急
treesofbayou
2010-12-17 02:08:41
有没有将TXT转换EXCEl的小程序?急
...全文
153
1
打赏
收藏
有没有将TXT转换EXCEl的小程序?急
有没有将TXT转换EXCEl的小程序?急
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
zhangxr123
2010-12-20
打赏
举报
回复
package com.sitech.tools.parseexcel;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class CreateBossExcel {
/**
* @param args
*/
private static final String path = "D://youhua//yangshuang";
public void createExcel(String path) throws IOException {
File file = new File(path);
if (file.exists() && file.isDirectory()) {
File[] subFile = file.listFiles();
for (int j = 0; j < subFile.length; j++) {
create(subFile[j], path);
System.out
.println("*********************************************"
+ subFile[j].getName());
}
} else {
System.out.println(path + "does not exist!");
}
}
private void create(File subfile, String path) throws IOException {
String filename = subfile.getName() + ".xls";
FileOutputStream fos = new FileOutputStream(filename);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
wb.setSheetName(0, filename);
HSSFRow row = null;
HSSFCell cell = null;
row = sheet.createRow(0);
cell = row.createCell((short) 0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("定时时间");
cell = row.createCell((short) 1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("定时代码路径");
cell = row.createCell((short) 2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("备注");
cell = row.createCell((short) 3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("添加人员");
cell = row.createCell((short) 4);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("是否涉及数据库");
cell = row.createCell((short) 5);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("是否需要修改");
LineNumberReader lnr = new LineNumberReader(new FileReader(subfile));
String line = null;
int ttt = 1;
String str1 = "";
String str2 = "";
String str3 = "";
while ((line = lnr.readLine()) != null){
if(line.startsWith("#")){
str1 = line.substring(line.indexOf("#"));
System.out.println(str1);
}else{
if(line.lastIndexOf("*") == -1){
}else{
str2 = line.substring(0,line.indexOf("*"));
str3 = line.substring(line.indexOf("/"),line.indexOf(".sh"));
}
}
if(!str1.equals("") && !str2.equals("") && !str3.equals("")){
row = sheet.createRow(ttt);
cell = row.createCell((short) 0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(str2);
cell = row.createCell((short) 1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(str3+".sh");
cell = row.createCell((short) 2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(str1);
cell = row.createCell((short) 3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(" ");
cell = row.createCell((short) 4);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(" ");
cell = row.createCell((short) 5);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(" ");
ttt++;
str1 = "";
str2 = "";
str3 = "";
}
}
System.out.println("ttt = "+ttt);
wb.write(fos);
fos.close();
}
public static void main(String[] args) throws IOException {
CreateBossExcel cbe = new CreateBossExcel();
cbe.createExcel(path);
}
}
VB
txt
转换
excel
的
小程序
本文提供了一段使用VBA将
TXT
文件
转换
为
Excel
文件的示例代码。该过程包括创建
Excel
对象、读取
TXT
文件内容并按指定字符拆分数据,最后将数据逐行写入到新的
Excel
文件中。
用python将
txt
文件中的内容导入到
excel
文件中
这篇博客介绍了如何利用Python的openpyxl模块将日志文件内容
转换
为
Excel
表格,便于阅读和统计。首先,解释了日志文件的背景和格式,然后展示了实现这一功能的代码,包括创建工作簿、工作表,设置表头,写入单元格,以及读取和保存工作簿。最后,提到了使用codecs和tqdm库进行进度显示,并提供了将
txt
文件导出到csv文件的补充代码。
txt
转
excel
的工具
本文介绍了一个简单的Python程序,用于将
TXT
文件
转换
为
Excel
文件。该程序使用了pandas库,并提供了一个示例函数,展示了如何从
TXT
文件读取数据并将其保存为
Excel
格式。适用于深度学习项目中不同数据格式之间的
转换
需求。
2026保姆级
Excel
转
txt
教程:多种
excel
转
txt
方法,
Excel
另存为文本文件详细步骤
本文系统介绍2026年主流
Excel
转
TXT
方法:微信
小程序
(青蓝PDF
转换
)、Office/WPS原生另存为、局部复制粘贴、CSV中转法、VBA批量导出。重点解决中文乱码、单表限制、批量效率等痛点,覆盖手机端快速处理、电脑本地安全导出、专业自动化场景,适配不同用户技术基础与数据规模需求。
Java
51,408
社区成员
86,098
社区内容
发帖
与我相关
我的任务
Java
Java相关技术讨论
复制链接
扫一扫
分享
社区描述
Java相关技术讨论
java
spring boot
spring cloud
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章