1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > java 导入world数据_java读取world文件 把world文件中的内容 原样输出到页面上。...

java 导入world数据_java读取world文件 把world文件中的内容 原样输出到页面上。...

时间:2020-09-24 18:44:16

相关推荐

java 导入world数据_java读取world文件 把world文件中的内容 原样输出到页面上。...

POI,处理可以。样式在Java代码中添加就可以。给了一个例子这个是Excel的。package cn.mon;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.SQLException;

import org.apache.log4j.Logger;

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;

import org.apache.poi.poifs.filesystem.POIFSFileSystem;

/**

* DB2Excel 工具类

*

* @see

*/

public class DB2ExcelUtils {

private static String systemSeparator = System.getProperty("file.separator");

/**

* 编辑Excel POI

* @param db

* @param conn

* @param file

* @param strSQL

* @param logger

* @throws IOException

* @throws BiffException

* @throws SQLException

* @throws WriteException

* @throws InterruptedException

*/

public static void editExcelPOI_WXNL(String newPath,File file,Logger logger) throws IOException,

SQLException, InterruptedException {

//

String newFilePath = "";

// file

logger.debug("DB2Excel--editExcelPOI--file=" + file.getName() + ";编辑开始");

// 取得新数据文件

newFilePath = newPath + systemSeparator + file.getName();

File outFile = new File(newFilePath);

logger.debug("DB2Excel--editExcelPOI--取得新数据文件file=" + outFile.getPath());

if(!outFile.exists()){

outFile.createNewFile();

logger.debug("DB2Excel--editExcelPOI--file=" + outFile.getName() + ";新建文件");

}

FileOutputStream templetOut = new FileOutputStream(outFile);//选择目标文件

POIFSFileSystem templetIn = new POIFSFileSystem(new FileInputStream(file));//读入模版

HSSFWorkbook wbTemplet = new HSSFWorkbook(templetIn);//创建HSSFWorkbook

HSSFSheet sheetTemplet = wbTemplet.getSheetAt(0);//创建HSSFSheet

//int ic = 0; // 列

//int ir = 0; // 行

//int ic = 9;//9\10\11\13\14\15\

// for(int i = 13; i < 18; i++) {

// switch(i) {

// case 13:

// ic = 13;

// break;

// case 14:

// ic = 14;

// break;

// case 15:

// //ic = 15;

// break;

// case 16:

// ic = 16;

// break;

// case 17:

// ic = 17;

// }

int ic = 13;

HSSFRow hr = sheetTemplet.getRow(7);

HSSFCell hc = hr.getCell((short)ic);

//hc.setCellType(HSSFCell.CELL_TYPE_STRING);

hc.setCellValue(""); // 单元格赋值

// }

//写入Excel对象

wbTemplet.write(templetOut);

// 关闭输出流

templetOut.close();

// file

logger.debug("DB2Excel--editExcelPOI--file=" + file.getPath() + ";编辑正常结束");

}

}

8月29日 10:44

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。