社区
Java
帖子详情
有没有将TXT转换EXCEl的小程序?急
treesofbayou
2010-12-17 02:08:41
有没有将TXT转换EXCEl的小程序?急
...全文
123
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);
}
}
txt
转
excel
的工具
用pandas将
txt
数据文件
转换
为
excel
文件
VB
txt
转换
excel
的
小程序
首先要对
excel
进行引用 Private Sub Command1_Click()Sub Command1_Click()
Txt
To
Excel
"E:/1.
txt
", " " End SubSub
Txt
To
Excel
()Sub
Txt
To
Excel
(
txt
File As String, DistanceChar As String)On ...
python 将
excel
文件
转换
为
txt
文件_python实现
Excel
文件
转换
为
TXT
文件
python读取
excel
的指定内容
转换
成配置命令写入
txt
文档小编只是个孩子,只要给小编一颗糖,小编就可以幸福到心酸。python读取
excel
的指定内容
转换
成配置写入
txt
文档
excel
从第二行开始,import xlrddef strs(row): ...
微信
小程序
生成
Excel
最近一直在查找在微信
小程序
中生成
Excel
的办法。需求就是根据一个json数据或者对象数组,生成一个
Excel
文件,或者打开
Excel
文件。网上找了很久,没找到很有效的解决办法。最后自己动手做了一个,不过生成效率还比较...
微信
小程序
如何实现将数据导出生成
excel
码字不易,有帮助的同学希望能关注一下我的微信公众号:Code程序人生,感谢!代码自用自取。 这个需求也是我在接私活的时候遇到的,需求就是,要实现将指定数据库表的数据全部导出生成
excel
和按需导出,也就是导出...
Java
50,526
社区成员
85,605
社区内容
发帖
与我相关
我的任务
Java
Java相关技术讨论
复制链接
扫一扫
分享
社区描述
Java相关技术讨论
java
spring boot
spring cloud
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章