Apache POI および Aspose.Cells での境界線の操作

Aspose.Cells - ボーダーの操作

Aspose.Cells はクラスを提供し、ワークブックMicrosoft Excel ファイルを表します。 Workbook クラスには、Excel ファイル内の各ワークシートへのアクセスを許可する WorksheetCollection が含まれています。ワークシートは、ワークシートクラス。 Worksheet クラスは Cellscollection を提供します。 Cells コレクションの各アイテムは、Cellクラス。

Aspose.Cells は、setStyle メソッドをCellセルのフォーマット スタイルを設定するために使用されるクラス。また、の Style オブジェクトスタイルクラスが使用され、フォント設定を構成するためのプロパティを提供します。

Java

 // Style the cell with borders all around.

Style style = workbook.createStyle();

style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());

style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getGreen());

style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlue());

style.setBorder(BorderType.TOP_BORDER, CellBorderType.MEDIUM_DASH_DOT, Color.getBlack());

// Setting style to the cell

cell.setStyle(style);

Apache POI SS - HSSF XSSF - ボーダーの操作

CellStyle クラスは、Apache POI SS - HSSF および XSSF を使用してボーダー設定を設定する機能を提供します。

Java

 //Setting the line of the top border

style.setBorder(BorderType.TOP_BORDER,CellBorderType.THICK,Color.getBlack());

//Setting the line of the bottom border

style.setBorder(BorderType.BOTTOM_BORDER,CellBorderType.THICK,Color.getBlack());

//Setting the line of the left border

style.setBorder(BorderType.LEFT_BORDER,CellBorderType.THICK,Color.getBlack());

//Setting the line of the right border

style.setBorder(BorderType.RIGHT_BORDER,CellBorderType.THICK,Color.getBlack());

//Saving the modified style to the "A1" cell.

cell.setStyle(style);

実行中のコードをダウンロード

サンプルコードをダウンロード