public class ExcelWriter
extends java.lang.Object
Example 1:
final byte[] data = ExcelBuilder
.createXlsx()
.withSheet("Persons", Person.class)
.withColumn("FirstName", Person::getFirstName)
.withColumn("LastName", Person::getLastName)
.withColumn("Age", Person::getAge)
.renderData(persons())
.autoSizeColumns()
.end()
.writeToBytes();
Example 2 (header row format):
final byte[] data = ExcelBuilder
.createXlsx()
.withFont("bold").bold().end()
.withFont("italic").italic().end()
.withCellStyle("header").font("bold").end()
.withSheet("Persons", Person.class)
.defaultHeaderStyle("header")
.withColumn("FirstName", Person::getFirstName)
.withColumn("LastName", Person::getLastName)
.withColumn("Age", Person::getAge)
.renderData(persons)
.renderData(getQueryStatistics())
.autoSizeColumns()
.end()
.writeToBytes();
Example 3 (footer SUM):
final List<DataRecord> persons = persons();
final byte[] data = ExcelBuilder
.createXlsx()
.withSheet("Persons", Person.class)
.withColumn("FirstName")
.colMapper(Person::getFirstName)
.footerTextValue("SUM age")
.end()
.withColumn("LastName")
.colMapper(Person::getLastName)
.end()
.withColumn("Age")
.colMapper(Person::getAge)
.footerSum()
.end()
.renderData(persons)
.autoSizeColumns()
.end()
.writeToBytes();
Example 4 (footer SUM with styles):
final List<DataRecord> persons = persons();
final byte[] data = ExcelBuilder
.createXlsx()
.withFont("bold").bold().end()
.withFont("bold-blue").bold().color(IndexedColors.BLUE).end()
.withCellStyle("header").font("bold").bgColor(IndexedColors.GREY_25_PERCENT).end()
.withCellStyle("age").format("#,##0").end()
.withCellStyle("sum-header").font("bold").end()
.withCellStyle("sum-age").font("bold-blue").format("#,##0").end()
.withSheet("Persons", Person.class)
.defaultHeaderStyle("header")
.withColumn("FirstName")
.colMapper(Person::getFirstName)
.footerTextValue("SUM age")
.footerStyle("sum-header")
.end()
.withColumn("LastName")
.colMapper(Person::getLastName)
.end()
.withColumn("Age")
.colMapper(Person::getAge)
.bodyStyle("age")
.footerSum()
.footerStyle("sum-age")
.end()
.renderData(persons)
.autoSizeColumns()
.end()
.writeToBytes();
| Constructor and Description |
|---|
ExcelWriter(com.github.jlangch.venice.impl.util.excel.Excel managedExcel) |
| Modifier and Type | Method and Description |
|---|---|
static ExcelWriter |
createXls() |
static ExcelWriter |
createXlsx() |
ExcelWriter |
end() |
void |
evaluateAllFormulas() |
int |
getNumberOfSheets() |
<T> ExcelSheetWriter<T> |
getSheet(java.lang.String name) |
<T> ExcelSheetWriter<T> |
getSheetAt(int sheetIdx) |
ExcelReader |
reader() |
com.github.jlangch.venice.impl.util.excel.Excel |
toExcel() |
ExcelCellStyleBuilder |
withCellStyle(java.lang.String name) |
ExcelFontBuilder |
withFont(java.lang.String name) |
<T> ExcelSheetWriter<T> |
withSheet(java.lang.String name,
java.lang.Class<T> type) |
void |
write(java.io.OutputStream outputStream) |
byte[] |
writeToBytes() |
public ExcelWriter(com.github.jlangch.venice.impl.util.excel.Excel managedExcel)
public static ExcelWriter createXls()
public static ExcelWriter createXlsx()
public ExcelFontBuilder withFont(java.lang.String name)
public ExcelCellStyleBuilder withCellStyle(java.lang.String name)
public <T> ExcelSheetWriter<T> withSheet(java.lang.String name, java.lang.Class<T> type)
public int getNumberOfSheets()
public void evaluateAllFormulas()
public com.github.jlangch.venice.impl.util.excel.Excel toExcel()
public void write(java.io.OutputStream outputStream)
public byte[] writeToBytes()
public ExcelReader reader()
public ExcelWriter end()
public <T> ExcelSheetWriter<T> getSheet(java.lang.String name)
public <T> ExcelSheetWriter<T> getSheetAt(int sheetIdx)