Skip to content

Commit 39bc89a

Browse files
committed
This closes #2108, Add documentation to SheetPropsOptions for 1) No Scaling; 2) Fit Sheet on One Page; 3) Fit All Columns on One Page; 4) Fit All Rows on One Page
1 parent d399e7b commit 39bc89a

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

Diff for: xmlWorksheet.go

+52-1
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,58 @@ type ViewOptions struct {
10711071
ZoomScale *float64
10721072
}
10731073

1074-
// SheetPropsOptions directly maps the settings of sheet view.
1074+
// SetSheetProps provides a function to set worksheet properties. There 4 kinds
1075+
// of presets "Custom Scaling Options" in the spreadsheet applications, if you
1076+
// need to set those kind of scaling options, please using the "SetSheetProps"
1077+
// and "SetPageLayout" functions to approach these 4 scaling options:
1078+
//
1079+
// 1. No Scaling (Print sheets at their actual size):
1080+
//
1081+
// disable := false
1082+
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
1083+
// FitToPage: &disable,
1084+
// }); err != nil {
1085+
// fmt.Println(err)
1086+
// }
1087+
//
1088+
// 2. Fit Sheet on One Page (Shrink the printout so that it fits on one page):
1089+
//
1090+
// enable := true
1091+
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
1092+
// FitToPage: &enable,
1093+
// }); err != nil {
1094+
// fmt.Println(err)
1095+
// }
1096+
//
1097+
// 3. Fit All Columns on One Page (Shrink the printout so that it is one page
1098+
// wide):
1099+
//
1100+
// enable, zero := true, 0
1101+
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
1102+
// FitToPage: &enable,
1103+
// }); err != nil {
1104+
// fmt.Println(err)
1105+
// }
1106+
// if err := f.SetPageLayout("Sheet1", &excelize.PageLayoutOptions{
1107+
// FitToHeight: &zero,
1108+
// }); err != nil {
1109+
// fmt.Println(err)
1110+
// }
1111+
//
1112+
// 4. Fit All Rows on One Page (Shrink the printout so that it is one page
1113+
// high):
1114+
//
1115+
// enable, zero := true, 0
1116+
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
1117+
// FitToPage: &enable,
1118+
// }); err != nil {
1119+
// fmt.Println(err)
1120+
// }
1121+
// if err := f.SetPageLayout("Sheet1", &excelize.PageLayoutOptions{
1122+
// FitToWidth: &zero,
1123+
// }); err != nil {
1124+
// fmt.Println(err)
1125+
// }
10751126
type SheetPropsOptions struct {
10761127
// Specifies a stable name of the sheet, which should not change over time,
10771128
// and does not change from user input. This name should be used by code

0 commit comments

Comments
 (0)