Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ajokela
Created October 11, 2011 20:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajokela/1279397 to your computer and use it in GitHub Desktop.
Save ajokela/1279397 to your computer and use it in GitHub Desktop.
Apache POI (Excel in Java) - Span Multiple Columns with Cell
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet();
CellRangeAddress region = new CellRangeAddress( rowIdx, rowIdx, columnIdx, columnIdx+1);
sheet.addMergedRegion(region);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment