Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetHeaderFooter setting ScaleWithDoc & AlignWithMargins do not appear to work #1645

Closed
fnickels opened this issue Sep 2, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@fnickels
Copy link
Contributor

fnickels commented Sep 2, 2023

Description

When calling SetHeaderFooter() with either or both ScaleWithDoc & AlignWithMargins these settings do not appear to change when opening the resulting Excel document.

Steps to reproduce the issue:

  1. Use code similar to that shown below
  2. Write Excel file
  3. Open the file with Excel
  4. Navigate to Page Layout -> Page Setup -> Header/Footer
  5. Both check boxes are still checked
	if err := tp.excelFile.SetHeaderFooter("Sheet1", &excelize.HeaderFooterOptions{
		OddHeader:        "&R&D &T",
		OddFooter:        "&L&F&C&A&RPage: &P/&N",
		ScaleWithDoc:     false,
		AlignWithMargins: false,
	}); err != nil {
		return err
	}

Describe the results you received:

image

Describe the results you expected:

Expected both check boxes to be unchecked.

Output of go version:

go version go1.20.7 linux/amd64

Excelize version or commit ID:

	github.com/xuri/excelize/v2 v2.7.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):

WSL2 under Windows, Ubuntu 22.04

@xuri xuri added bug Something isn't working in progress Working in progress labels Sep 8, 2023
@xuri xuri closed this as completed in 49706c9 Sep 9, 2023
@xuri
Copy link
Member

xuri commented Sep 9, 2023

Thanks for your issue. I have changed the data type for the AlignWithMargins and ScaleWithDoc fields to fix this. Please try to upgrade the master branch code, and this patch will be released in the next version. You can set AlignWithMargins and ScaleWithDoc like this:

+disable := false
 if err := tp.excelFile.SetHeaderFooter("Sheet1", &excelize.HeaderFooterOptions{
     OddHeader:        "&R&D &T",
     OddFooter:        "&L&F&C&A&RPage: &P/&N",
-    ScaleWithDoc:     false,
-    AlignWithMargins: false,
+    ScaleWithDoc:     &disable,
+    AlignWithMargins: &disable,
 }); err != nil {
     return err
 }

@xuri xuri removed the in progress Working in progress label Sep 9, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- Breaking changes, change the data type for the `HeaderFooterOptions` structure fields `AlignWithMargins` and `ScaleWithDoc` as a pointer
- Fixed panic on `AutoFilter` by adding nil pointer guard for local sheet ID
- Allow dot character in the defined name, table name, or pivot table name
- Update the unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants