相关疑难解决方法(0)

使用Apache POI删除特定Excel工作表上的所有边框

我正在使用Apache POI生成Excel文件.我需要删除工作表中的所有边框.如何使用Apache PIO 3.11和Microsoft Excel 2007实现此目的?

这是我到目前为止的代码:

package models;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;

import java.io.FileOutputStream;
import java.util.List;
public class Excel {

    public static void writeDocument() {
        Workbook workbook = new HSSFWorkbook();
        Sheet sheet = workbook.createSheet("sheet");
        //first font
        Font font1 = workbook.createFont();
        font1.setBoldweight(Font.BOLDWEIGHT_BOLD);
        //first style
        CellStyle style1 = workbook.createCellStyle();
        style1.setBorderLeft(CellStyle.BORDER_NONE);
        style1.setBorderRight(CellStyle.BORDER_NONE);
        style1.setBorderBottom(CellStyle.BORDER_NONE);
        style1.setBorderTop(CellStyle.BORDER_NONE);

        //second style
        CellStyle style2 =  workbook.createCellStyle();
        style2.setFont(font1);
        style2.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style2.setAlignment(CellStyle.ALIGN_CENTER);
        style2.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
        style2.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style2.setBorderBottom(CellStyle.BORDER_THIN);
        style2.setBottomBorderColor(IndexedColors.GREY_25_PERCENT.getIndex());
        style2.setBorderLeft(CellStyle.BORDER_THIN);
        style2.setLeftBorderColor(IndexedColors.GREY_25_PERCENT.getIndex());
        style2.setBorderRight(CellStyle.BORDER_THIN);
        style2.setRightBorderColor(IndexedColors.GREY_25_PERCENT.getIndex());
        style2.setBorderTop(IndexedColors.GREY_25_PERCENT.getIndex());

        for(int i=0; i< 100 ; i++){ …
Run Code Online (Sandbox Code Playgroud)

java apache-poi

10
推荐指数
1
解决办法
7495
查看次数

标签 统计

apache-poi ×1

java ×1