主要代码:
/**
* 生成图片
* @param cellsValue 以二维数组形式存放 表格里面的值
* @param path 文件保存路径
*/
public void myGraphicsGeneration(String cellsValue[][], String path) {
// 字体大小
int fontTitileSize = 15;
// 横线的行数
int totalrow = cellsValue.length+1;
// 竖线的行数
int totalcol = 0;
if (cellsValue[0] != null) {
totalcol = cellsValue[0].length;
}
// 图片宽度
int imageWidth = 1024;
// 行高
int rowheight = 40;
// 图片高度
int imageHeight = totalrow*rowheight+50;
// 起始高度
int startHeight = 10;
// 起始宽度
int startWidth = 10;
// 单元格宽度
int colwidth = (int)((imageWidth-20)/totalcol);
BufferedImage image = new BufferedImage(imageWidth, imageHeight,BufferedImage.TYPE_IN