>>下面的这个简单的程序可以写入中英文,看看对你有没有帮助import org.apache.poi.hssf.usermodel.*;
import java.io.*;
import org.apache.log4j.*;
import org.apache.log4j.PropertyConfigurator;public class poitest
{
public void write() throws FileNotFoundException,IOException
{
FileOutputStream fos = new FileOutputStream("test.xls");
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet ws = wb.createSheet("first");
HSSFRow row = ws.createRow(0);
HSSFCell cell = null;
for(int i=0;i<10;i++)
{
cell = row.createCell((short)i);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
//cell.setCellValue("fgfgfgfgfg");
cell.setCellValue("中国");
}
wb.write(fos);
fos.close();
}
public static void main(String[] args) throws FileNotFoundException,IOException
{
poitest pt = new poitest();
pt.write();
}
}
import java.io.*;
import org.apache.log4j.*;
import org.apache.log4j.PropertyConfigurator;public class poitest
{
public void write() throws FileNotFoundException,IOException
{
FileOutputStream fos = new FileOutputStream("test.xls");
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet ws = wb.createSheet("first");
HSSFRow row = ws.createRow(0);
HSSFCell cell = null;
for(int i=0;i<10;i++)
{
cell = row.createCell((short)i);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
//cell.setCellValue("fgfgfgfgfg");
cell.setCellValue("中国");
}
wb.write(fos);
fos.close();
}
public static void main(String[] args) throws FileNotFoundException,IOException
{
poitest pt = new poitest();
pt.write();
}
}
cell.setEncoding(HSSFCell.ENCODING_UTF_16)
具体的参照POI的API文档:)