package com.xiejiaohui.dc; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.text.SimpleDateFormat; import java.util.Date; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; public class Txt2Excel_xxx { public static void main(String[] args) throws Exception { Date beginDate = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:sss"); System.out.println(sdf.format(beginDate)); BufferedReader bf0 = new BufferedReader(new FileReader(new File( "d:\\ql\\rpt_ckyebw.txt"))); String s0 = null; int i0 = 0; while ((s0 = bf0.readLine()) != null) { i0++; } bf0.close(); int sheet_number = i0 / 35564 + 1; for (int kk = 0; kk < sheet_number; kk++) { WritableWorkbook book = Workbook.createWorkbook(new File( "d:\\ql\\x" + kk + ".xls")); BufferedReader bf1 = new BufferedReader(new FileReader(new File( "d:\\ql\\rpt_ckyebw.txt"))); WritableSheet sheet = book.createSheet("xjh" + kk, kk); String s = null; int i = 0; while ((s = bf1.readLine()) != null) { if (s.contains("@!")) { if (s.length() > 0) { String[] s2 = s.split("@!"); if (s2.length != 12) { // System.out.println("error line number: " + i); // i++; // continue; s = s + " "; s2 = s.split("@!"); } if (i >= (35564 * kk) && i < (35564 * ( kk + 1))) { // System.out.println(i); sheet.addCell(new Label(0, i - (35564 * kk) , s2[0])); sheet.addCell(new Label(1, i - (35564 * kk), s2[1])); sheet.addCell(new Label(2, i - (35564 * kk), s2[2])); sheet.addCell(new Label(3, i - (35564 * kk), s2[3])); sheet.addCell(new Label(4, i - (35564 * kk), s2[4])); sheet.addCell(new Label(5, i - (35564 * kk), s2[5])); sheet.addCell(new Label(6, i - (35564 * kk), s2[6])); sheet.addCell(new Label(7, i - (35564 * kk), s2[7])); sheet.addCell(new Label(8, i - (35564 * kk), s2[8])); sheet.addCell(new Label(9, i - (35564 * kk), s2[9])); sheet.addCell(new Label(10, i - (35564 * kk), s2[10])); if (null != s2[11] && (!"".equals(s2[11]))) { sheet.addCell(new Label(11, i - (35564 * kk), s2[11])); } } } } i++; } book.write(); book.close(); bf1.close(); } Date endDate = new Date(); System.out.println(sdf.format(endDate)); System.out.println("ok"); } }
package com.xiejiaohui.dc; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; public class Txt2Excel_rpt_dkye { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new FileReader(new File( "d:\\ql\\rpt_dkye.txt"))); WritableWorkbook book = Workbook.createWorkbook(new File( "d:\\ql\\rpt_dkye.xls")); WritableSheet sheet = book.createSheet("xjh", 0); String s = null; int i = 0; while ((s = br.readLine()) != null) { if (s.contains("@!")) { if (s.length() > 0) { String[] s2 = s.split("@!"); if (s2.length != 21) { System.out.println("error line: " + i); } sheet.addCell(new Label(0, i, s2[0])); sheet.addCell(new Label(1, i, s2[1])); sheet.addCell(new Label(2, i, s2[2])); sheet.addCell(new Label(3, i, s2[3])); sheet.addCell(new Label(4, i, s2[4])); sheet.addCell(new Label(5, i, s2[5])); sheet.addCell(new Label(6, i, s2[6])); sheet.addCell(new Label(7, i, s2[7])); sheet.addCell(new Label(8, i, s2[8])); sheet.addCell(new Label(9, i, s2[9])); sheet.addCell(new Label(10, i, s2[10])); sheet.addCell(new Label(11, i, s2[11])); sheet.addCell(new Label(12, i, s2[12])); sheet.addCell(new Label(13, i, s2[13])); sheet.addCell(new Label(14, i, s2[14])); sheet.addCell(new Label(15, i, s2[15])); sheet.addCell(new Label(16, i, s2[16])); sheet.addCell(new Label(17, i, s2[17])); sheet.addCell(new Label(18, i, s2[18])); sheet.addCell(new Label(19, i, s2[19])); sheet.addCell(new Label(20, i, s2[20])); } } i++; } book.write(); book.close(); br.close(); System.out.println("ok"); } }
package com.xiejiaohui.dc; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; public class Txt2Excel_rpt_dkfse { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new FileReader(new File( "d:\\ql\\rpt_dkfse.txt"))); WritableWorkbook book = Workbook.createWorkbook(new File( "d:\\ql\\rpt_dkfse.xls")); WritableSheet sheet = book.createSheet("xjh", 0); String s = null; int i = 0; while ((s = br.readLine()) != null) { if (s.contains("@!")) { if (s.length() > 0) { String[] s2 = s.split("@!"); if (s2.length != 21) { System.out.println("error line: " + i); } sheet.addCell(new Label(0, i, s2[0])); sheet.addCell(new Label(1, i, s2[1])); sheet.addCell(new Label(2, i, s2[2])); sheet.addCell(new Label(3, i, s2[3])); sheet.addCell(new Label(4, i, s2[4])); sheet.addCell(new Label(5, i, s2[5])); sheet.addCell(new Label(6, i, s2[6])); sheet.addCell(new Label(7, i, s2[7])); sheet.addCell(new Label(8, i, s2[8])); sheet.addCell(new Label(9, i, s2[9])); sheet.addCell(new Label(10, i, s2[10])); sheet.addCell(new Label(11, i, s2[11])); sheet.addCell(new Label(12, i, s2[12])); sheet.addCell(new Label(13, i, s2[13])); sheet.addCell(new Label(14, i, s2[14])); sheet.addCell(new Label(15, i, s2[15])); sheet.addCell(new Label(16, i, s2[16])); sheet.addCell(new Label(17, i, s2[17])); sheet.addCell(new Label(18, i, s2[18])); sheet.addCell(new Label(19, i, s2[19])); sheet.addCell(new Label(20, i, s2[20])); } } i++; } book.write(); book.close(); br.close(); System.out.println("ok"); } }