Skip to content

Commit

Permalink
rich text styles formatting, fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed Oct 14, 2015
1 parent ca12eb0 commit 79a7c1b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,12 @@ _Result_

image:rich_text.png[]

[WARNING]
====
Some older versions that 3.13 of Apache POI does not handle rich texts well. Please, make sure
you are using at least version 3.13.
====

=== Data formats
You can assing a data format using the `format` method. Detailed guide how the format works can be found in
link:https://support.microsoft.com/en-us/kb/298368[How to control and understand settings in the Excel for Format Cells
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ class PoiCell extends AbstractCell implements Resolvable {

@Override
void text(String run, @DelegatesTo(Font.class) @ClosureParams(value = FromString.class, options = "org.modelcatalogue.builder.spreadsheet.api.Font") Closure fontConfiguration) {
if (!run) {
return
}
int start = 0
if (richTextParts) {
start = richTextParts.last().end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PoiFont extends AbstractHTMLColorProvider implements Font {

@Override
void size(int size) {
font.fontHeightInPoints = (short) size
font.setFontHeightInPoints(size.shortValue())
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,59 @@ class PoiExcelBuilderSpec extends Specification {

}
}
row {
cell {
style {
wrap text
}
text 'First Line'
text '\n'
text 'Second Line', {
bold
size 12
}
text '\n'
for (Map.Entry<String, String> entry in [foo: 'bar', boo: 'cow', empty: '', '':'nothing']) {
text entry.key, {
bold
}
text ': '
text entry.value
text '\n'
}
text '\n\n'
text 'Next line after two spaces'
text '\n'
text 'Last line', {
italic
}
text '\n'
}
}

row {
cell {
text 'Genomics England Consent Withdrawal Options'
text '\n\n'
text 'Enumerations', {
size 12
bold
}
text '\n'

for (Map.Entry<String, String> entry in [
FULL_WITHDRAWAL: 'OPTION 2: FULL WITHDRAWAL: No further use',
PARTIAL_WITHDRAWAL: 'OPTION 1: PARTIAL WITHDRAWAL: No further contact'
]) {
text entry.key, {
bold
}
text ': '
text entry.value
text '\n'
}
}
}
}

sheet('Cell Adressing') {
Expand Down

0 comments on commit 79a7c1b

Please sign in to comment.