-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tagging version v1.0.3 v1.0.3
- Loading branch information
Showing
25 changed files
with
337 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package code | ||
|
||
import ( | ||
"github.com/plandem/xlsx/format/styles" | ||
) | ||
|
||
func Example_stylesFont() { | ||
//all possible settings for font | ||
styles.New( | ||
styles.Font.Name("Courier New"), | ||
styles.Font.Bold, | ||
styles.Font.Italic, | ||
styles.Font.Strikeout, | ||
styles.Font.Superscript, | ||
styles.Font.Subscript, | ||
styles.Font.Shadow, | ||
styles.Font.Condense, | ||
styles.Font.Extend, | ||
styles.Font.Family(styles.FontFamilyRoman), | ||
styles.Font.Color("#FF0000"), | ||
styles.Font.Size(16), | ||
styles.Font.Underline(styles.UnderlineTypeSingle), | ||
styles.Font.Scheme(styles.FontSchemeMinor), | ||
styles.Font.Charset(styles.FontCharsetMAC), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Number Format Codes | ||
[[toc]] | ||
Number format code is way to show numeric value. It controls whether a number is displayed as an integer, a floating number, a date, a currency value or some other user defined format. | ||
|
||
::: tip | ||
Xlsx2Go supports built-in Excel codes and will try to detect/convert to proper internal ID, as well as custom codes - use it as is without worrying. | ||
::: | ||
|
||
### Built-in Codes | ||
::: note General type | ||
* `@` | ||
* `General` | ||
::: | ||
|
||
::: note Integer number | ||
* `0` | ||
* `0%` | ||
* `(#,##0_);(#,##0)` | ||
* `(#,##0_);[RED](#,##0)` | ||
::: | ||
|
||
::: note Float number | ||
* `0.00` | ||
* `#,##0` | ||
* `#,##0.00` | ||
* `($#,##0_);($#,##0)` | ||
* `($#,##0_);[RED]($#,##0)` | ||
* `($#,##0.00_);($#,##0.00_)` | ||
* `($#,##0.00_);[RED]($#,##0.00_)` | ||
* `0.00%` | ||
* `0.00E+00` | ||
* `# ?/?` | ||
* `# ??/??` | ||
* `(#,##0.00);(#,##0.00)` | ||
* `(#,##0.00);[RED](#,##0.00)` | ||
* `_(*#,##0_);_(*(#,##0);_(*"-"_);_(@_)` | ||
* `_($*#,##0_);_($*(#,##0);_(*"-"_);_(@_)` | ||
* `_(*#,##0.00_);_(*(#,##0.00);_(*"-"??_);_(@_)` | ||
* `_($*#,##0.00_);_($*(#,##0.00);_(*"-"??_);_(@_)` | ||
* `##0.0E+0` | ||
::: | ||
|
||
::: note Date | ||
* `m-d-yy` | ||
* `d-mmm-yy` | ||
* `d-mmm` | ||
* `mmm-yy` | ||
::: | ||
|
||
::: note Time | ||
* `h:mm AM/PM` | ||
* `h:mm:ss AM/PM` | ||
* `h:mm` | ||
* `h:mm:ss` | ||
::: | ||
|
||
::: note Date+Time | ||
* `m-d-yy h:mm` | ||
::: | ||
|
||
::: note DeltaTime | ||
* `mm:ss` | ||
* `[h]:mm:ss` | ||
* `mm:ss.0` | ||
::: | ||
|
||
### Custom Codes | ||
Format code can control any aspect of number formatting allowed by Excel: | ||
|
||
::: tip Currency | ||
The `$` in format appears as the local currency symbol. | ||
::: | ||
|
||
::: tip Colors | ||
The color format should have one of the following values: | ||
|
||
`[Black]` `[Blue]` `[Cyan]` `[Green]` `[Magenta]` `[Red]` `[White]` `[Yellow]` | ||
::: | ||
|
||
#### Examples | ||
<table> | ||
<tr> | ||
<th style="text-align: right;">Number code</th> | ||
<th style="text-align: right;">Go Value</th> | ||
<th style="text-align: right;">Excel Output</th> | ||
</th> | ||
<tr> | ||
<td style="text-align: right;"><code>dd/mm/yyyy hh:mm AM/PM</code></td> | ||
<td style="text-align: right;">time.Now()</td> | ||
<td style="text-align: right;">18/07/2019 12:30 AM</td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;"><code>mm/dd/yy</code></td> | ||
<td style="text-align: right;">time.Now()</td> | ||
<td style="text-align: right;">07/18/19</td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;"><code>mmm d yyyy</code></td> | ||
<td style="text-align: right;">time.Now()</td> | ||
<td style="text-align: right;">Jul 18 2019</td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;"><code>d mmmm yyyy</code></td> | ||
<td style="text-align: right;">time.Now()</td> | ||
<td style="text-align: right;">18 July 2019</td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;"><code>0.000</code></td> | ||
<td style="text-align: right;">1.2345678</td> | ||
<td style="text-align: right;">1.235</td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;"><code>#,##0</code></td> | ||
<td style="text-align: right;">1234.567</td> | ||
<td style="text-align: right;">1,235</td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;"><code>0 "dollar and" .00 "cents"</code></td> | ||
<td style="text-align: right;">1.87</td> | ||
<td style="text-align: right;">1 dollar and .87 cents</td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;" rowspan="3"><code>[Green]General;[Red]-General;General</code></td> | ||
<td style="text-align: right;">12345</td> | ||
<td style="text-align: right;"><span style="color:green">1235</span></td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;">-12345</td> | ||
<td style="text-align: right;"><span style="color:red">-12345</span></td> | ||
</tr> | ||
<tr> | ||
<td style="text-align: right;">0</td> | ||
<td style="text-align: right;">0</td> | ||
</tr> | ||
</table> | ||
|
||
::: note | ||
|
||
::: right | ||
For more information about custom formats, check [Microsoft Documentation](https://support.office.com/en-us/article/create-a-custom-number-format-78f2a361-936b-4c03-8772-09fab54be7f4?ui=en-US&rs=en-US&ad=US) | ||
::: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,63 @@ | ||
# Styles Formatting | ||
[[toc]] | ||
|
||
Styles can be defined through special type - general type for all available styles. But information that will be using to style object, depends on usage, e.g. to style cells everything will be use, to style rich texts - only font information. | ||
|
||
```go | ||
// create a new styles | ||
ss := styles.New( | ||
styles.Font.Bold, | ||
styles.Font.Color("#ff0000"), | ||
) | ||
|
||
//update styles | ||
ss.Set( | ||
styles.Border.Color("#009000"), | ||
styles.Border.Type(styles.BorderStyleMedium), | ||
) | ||
``` | ||
::: warning Modify Styles | ||
While you can modify created styles, you should keep in mind, that modifying will work only before applying styles to cell and any modifications after applying, will create new styles. | ||
::: | ||
|
||
```go | ||
ss := styles.New( | ||
styles.Font.Bold, | ||
)) | ||
|
||
//font will be `bold` | ||
sheet.CellByRef("A1").SetStyles(ss) | ||
|
||
//modify styles | ||
ss.Set( | ||
styles.Font.Color("#ff0000"), | ||
) | ||
|
||
//`A2` - will be `bold and red` | ||
//`A1` - will be only `bold` and without color | ||
sheet.CellByRef("A2").SetStyles(ss) | ||
``` | ||
|
||
### Font | ||
::: warning | ||
Excel can only display installed fonts, that's why using standard fonts(e.g.: `Calibri`, `Times New Roman` or `Courier New`) is highly recommended. | ||
::: | ||
|
||
::: note | ||
The default font for cell is `Calibri` (Excel 2007+) | ||
::: | ||
<<< @/src/code/styles_font_test.go | ||
|
||
::: note Predefined values | ||
Xlsx2Go defined all built-in values to use for styling. For more information, check [API documentation](https://godoc.org/github.com/plandem/xlsx/format/styles#pkg-constants) | ||
::: | ||
|
||
### Fill | ||
|
||
### Border | ||
|
||
### Alignment | ||
|
||
### Numbers | ||
### Number Format | ||
|
||
### Protection |
Oops, something went wrong.