public class ExcelWriter
extends java.lang.Object
Example 1:
final byte[] data = ExcelWriter
.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 = ExcelWriter
.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 = ExcelWriter
.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 = ExcelWriter
.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 excel) |
| 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) |
static ExcelWriter |
open(byte[] document) |
static ExcelWriter |
open(java.nio.ByteBuffer document) |
static ExcelWriter |
open(java.io.File file) |
static ExcelWriter |
open(java.io.InputStream is) |
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.File file) |
void |
write(java.io.OutputStream outputStream) |
byte[] |
writeToBytes() |
public ExcelWriter(com.github.jlangch.venice.impl.util.excel.Excel excel)
public static ExcelWriter open(byte[] document)
public static ExcelWriter open(java.nio.ByteBuffer document)
public static ExcelWriter open(java.io.File file)
public static ExcelWriter open(java.io.InputStream is)
public static ExcelWriter createXls()
public static ExcelWriter createXlsx()
public int getNumberOfSheets()
public void evaluateAllFormulas()
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 void write(java.io.File file)
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)
public com.github.jlangch.venice.impl.util.excel.Excel toExcel()