一开始我想说我在开发者世界里是全新的.
我试图生成一个excel表,其中包含带边框的Mutiplication Table并设置背景颜色,但仅适用于第1列和第1行.
这是一个正确的例子:正确的例子
我写了类似的东西,但在结果文件中,彩色单元格没有边框:(.
请解释我如何同时设置背景颜色和边框.
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import java.awt.image.IndexColorModel;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class Excel {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
System.out.println("enter number of rows: ");
int x = in.nextInt();
System.out.println("enter number of columns: ");
int y = in.nextInt();
System.out.println("enter name of file: ");
String fileName = in.next() + ".xls";
System.out.println("Multiplication table will be created …Run Code Online (Sandbox Code Playgroud)