日期:2014-05-18  浏览次数:20591 次

求助:POI操作Excel的一个小问题。。。。。(在线等)
求助各位大虾:
        我通过POI创建了一个Excel的表格,想把其中各表格的边框去掉,但中间某部分又希望有一块小表格带有边框。。
        请问各位有没有人弄过类似的东西,多谢了!!!!

------解决方案--------------------
这个只能你自己定死了
首先让所有的表格没有边框,然后对你特定的几个单元格在设置上边框
================================================================
import org.apache.poi.hssf.usermodel.*;

import java.io.FileOutputStream;
import java.io.IOException;

/**
* Demonstrates how to create borders around cells.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class Borders
{
public static void main(String[] args)
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet( "new sheet ");

// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow((short) 1);

// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short) 1);
cell.setCellValue(4);

// Style the cell with borders all around.
HSSFCellStyle style = wb.createCellStyle();
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(HSSFCellStyle.BLACK);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFCellStyle.GREEN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setRightBorderColor(HSSFCellStyle.BLUE);
style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED);
style.setTopBorderColor(HSSFCellStyle.AUTOMATIC);
cell.setCellStyle(style);

// Write the output to a file
FileOutputStream fileOut = new FileOutputStream( "workbook.xls ");
wb.write(fileOut);
fileOut.close();
}
}
这是设置边框的例子,你可以对需要设置的单元格进行这样的操作
------解决方案--------------------
到网上找找HSSFCellStyle 相关的设置把,可能这个小细节只有你自己去试试才行,