If XLSX Footer replaced text contains a number, it gets added to the font size

Hi everyone

We are currently using Aspose.Cells.NET and are facing issues in certain xlsx files when we are replacing text in the footer. I could reproduce the issue in an attached demo project with a demo file. It seems to be a bug.

We are Replacing Placeholders in the whole document, but i modified the demo project so that i just replaces the footer placeholder “((Dokumentenname))”. If the replacement value, in our case the file name but it doesn’t matter, starts with a number, that number gets added to the applied font size and the text appears huge. This also happens only on the first page footer. Can you help us?

Demo Project:
Aspose.TestProject.7z (171.0 KB)

Actual Output (File in Project):
4 Testdokument BFO IOZ_out.pdf

Expected Output (File in Project):
4 Testdokument BFO IOZ Expected.pdf

@IOZ

Summary
When you replace a footer placeholder with a string that starts with a digit (e.g., “4 Testdokument …”), the first page (odd) footer becomes huge because the leading digit is interpreted as a font‑size code by Aspose.Cells. The other footers are not affected because they are stored in a different XML element.

Why it happens
Excel’s footer syntax uses an ampersand (&) followed by a number to change the font size (e.g., &12 → 12 pt). In the XLSX XML the footer text is stored as plain text, but Aspose.Cells parses the string for formatting codes. If the replacement text begins with a numeric character, the parser mistakenly treats that digit as a size token even though there is no preceding &. The parsed size is added to the default font size, which makes the text appear very large. This parsing is applied only to the <oddFooter> element, which explains why only the first‑page footer is affected.

What to do next

  1. Check your Aspose.Cells version
  • Open packages.config or the NuGet manager and note the exact version you are using.
  • Look at the release notes for newer versions – a fix for footer parsing may already exist. If a newer version is available, upgrade and retest.
  1. Verify the behaviour after an upgrade
worksheet.PageSetup.Footer = worksheet.PageSetup.Footer
.Replace("((Dokumentenname))", fileName);
workbook.Save("out.pdf", SaveFormat.Pdf);

If the large‑font issue disappears, the problem was fixed in the newer build.

  1. Work‑around if you cannot upgrade
  • Prepend a non‑numeric character or a space so the first character is not a digit:
string safeName = " " + fileName; // leading space prevents size parsing
worksheet.PageSetup.Footer = worksheet.PageSetup.Footer
.Replace("((Dokumentenname))", safeName);
  • Or explicitly set the font before the number using Excel’s escape sequence:
string safeName = "&\"Arial,Regular\"&11 4 Testdokument BFO IOZ";
worksheet.PageSetup.Footer = worksheet.PageSetup.Footer
.Replace("((Dokumentenname))", safeName);

Both approaches stop the parser from treating the leading digit as a size specifier.

  1. Inspect the generated XML (optional)
  • Save the workbook as XLSX, unzip it, and open xl/worksheets/sheetX.xml.
  • Look at the <oddFooter> element. If you see something like &4 Testdokument … the digit has been turned into a size code.
  1. If the issue persists
  • Gather the following information for a support request:
  • Exact Aspose.Cells for .NET version.
  • Minimal reproducible code that performs the placeholder replacement and saves the file (PDF or XLSX).
  • The original footer string before replacement.
  • Any PdfSaveOptions you use.
  • Submit the details to Aspose Support (or your internal support channel). The product team can confirm whether this is a bug and provide a fix or a more permanent workaround.

Note: The explanation above is based on the known Excel footer formatting rules and the observed behaviour you described. The official Aspose documentation does not currently contain a specific article about this exact scenario, so the suggested work‑arounds are the most reliable way to avoid the problem until a library update addresses it.

:warning: I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.

SDK version unclear — refer to the official release notes before applying this guidance.

Version is Aspose Cells 25.11

@IOZ
By testing with sample files and code on the latest version v25.11, we can reproduce the issue. Footer text abnormal display when converting file to pdf.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-59407

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@IOZ
As a temporary solution, you can specify the font and font size when setting the footer. Please modify the following sample code and check the result file. out_net.pdf (63.5 KB)

Please change the folowing code:

var replacements = new List<Replacement>
{
    new() { Placeholder = "((Dokumentenname))", Value = $"{filename}" }
};

To:

var replacements = new List<Replacement>
{
    new() { Placeholder = "((Dokumentenname))", Value = $"&\"Arial,Regular\"&14 {filename}" }
};

@IOZ
It should be the bug of MS Excel.
If you set font size of the header/footer and header/footer is a number, a space will be inserted.
There are two ways to fix this issue:
1, If you want to print current file name, you can use “&F” tag ,no need to replace by yourself.
2, Insert a space when replaced text.
var replacements = new List
{
new() { Placeholder = “((Dokumentenname))”, Value = $" {filename}" }
};

@IOZ ,

If you save to Excel xlsx file before saving to pdf, you will get the same result in Excel printview.

Please check attached screenshot of footer definition in Xml:
Screenshot_footer_definition.png (7.4 KB)
Your source file defines different first page for Header/Footer in page setup.
The first page footer: “Aptos,Standard” font with font size 6 for the text "((Dokumentenname))", there is no space char at the start of the text.
Other pages footer: font size 6 for the text " ((Dokumentenname))", there is a space char at the start of the text.
When you replace the text “((Dokumentenname))” with “4 Testdokument BFO IOZ”, the font size will be 64(there is no space between 6 and 4) for the first page. This is why the font size changed only for the first page.

Solutions:

  1. Re-design your source file to add a space at the begin for the first page Header/Footer.
  2. Add a space before replace text for safe as suggested.