社区
Java
帖子详情
有没有将TXT转换EXCEl的小程序?急
treesofbayou
2010-12-17 02:08:41
有没有将TXT转换EXCEl的小程序?急
...全文
127
1
打赏
收藏
有没有将TXT转换EXCEl的小程序?急
有没有将TXT转换EXCEl的小程序?急
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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
的
小程序
首先要对
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 Error GoTo L 建立e
txt
转
excel
的工具
用pandas将
txt
数据文件
转换
为
excel
文件
java
txt
转换
excel
_Java实现将
txt
文件转成xls文件的方法
最近项目用到
txt
文件和xls文件的
转换
,这里记录一下具体的思路。下面利用java代码实现
txt
转xls,这里要使用到jxl.jar包,这个包是通过java来操作
Excel
表格的工具类库。该jar包支持字体、数字、日期操作,能够修饰单元格属性,还能够支持图像和图表,基本上已经满足我们的日常操作,最主要的是这套API是纯Java实现的,在Windows和Linux操作系统下,它都可以正确的处理Exc...
python 将
excel
文件
转换
为
txt
文件_python实现
Excel
文件
转换
为
TXT
文件
python读取
excel
的指定内容
转换
成配置命令写入
txt
文档小编只是个孩子,只要给小编一颗糖,小编就可以幸福到心酸。python读取
excel
的指定内容
转换
成配置写入
txt
文档
excel
从第二行开始,import xlrddef strs(row): values = ""; for i in range(len(row)): if i == len(row) - 1: values = v...
小程序
——将
Excel
文件批量
转换
为csv格式
将一批
Excel
文件
转换
成csv格式。
Java
51,397
社区成员
85,847
社区内容
发帖
与我相关
我的任务
Java
Java相关技术讨论
复制链接
扫一扫
分享
社区描述
Java相关技术讨论
java
spring boot
spring cloud
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章