自动生成excell的 position
使用场景
使用页面生成,excell大量单元格,成千上百的量。如果量小就没必要使用。
要做Excell的table,而且要显示值,通过给td标签,添加一个postion(值是excell单元格位置)属性 来实现对大量table的赋值。具体代码地址
https://github.com/Notelzg/javaReview/tree/master/work/blog/excel-tools
code
parse 来自一个第三方的工程,下载地址是
import cn.com.goldwind.kit.excel.parser.ExcelFormulaToken;
import cn.com.goldwind.kit.excel.parser.ExcelFormulaTokenSubtype;
import cn.com.goldwind.kit.excel.parser.ExcelFormulaTokenType;
import cn.com.goldwind.kit.excel.processor.impl.ArgumentProcessor;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public void generete() throws IOException {
BufferedWriter bwnull = new BufferedWriter(new FileWriter("c://tdPosition.txt"));
String argument = "C58:AB59";
String sheet = "附表5年度利润表";
int rowLength = 27;
ExcelFormulaToken token = new ExcelFormulaToken(argument, ExcelFormulaTokenType.Argument, ExcelFormulaTokenSubtype.Range );
token.setSheetName(sheet);
ArgumentProcessor te = new ArgumentProcessor();
String[] cells = te.process(token).split(",");
for (int i=0;cells!=null && i < cells.length; i++){
if ((i) % rowLength == 0) {
System.out.println("<tr>");
bwnull.write("<tr>");
bwnull.newLine();
}
System.out.println("<td position=" + cells[i] + "></td>");
bwnull.write("<td position=" + cells[i] + "></td>");
bwnull.newLine();
if ((i+1) % rowLength == 0) {
System.out.println("</tr>");
bwnull.write("</tr");
bwnull.newLine();
}
}
bwnull.flush();
bwnull.close();
}