SOLVD BLOG

Fixing HTML Tags in Salesforce Formula Field Exports

Working with Salesforce records often involves exporting data to Excel for reporting or sharing. While Salesforce formula fields and reports display new lines or breaks perfectly on the platform, those line breaks can get lost during export—typically turning into HTML <br> tags or caret symbols that don’t translate into actual line breaks in Excel.

This blog post demonstrates a simple, reusable method to retain readable new lines directly in Excel exports using Salesforce formula fields and custom labels. This technique is especially useful for any object and scenario where you frequently export textual data and require preserved formatting for clarity or presentation.

The Problem with Exported Line Breaks

A common approach is to create a formula in Salesforce that includes <br> tags for line breaks. While this works well in Salesforce record pages and reports, exporting the content to Excel results in those tags appearing as plain text (<br>) rather than visual line breaks. This forces users to post-process the exported file or use additional Excel formulas to properly reformat the content—an inconvenient and potentially error-prone extra step.

The Custom Label Solution

Instead of dealing with post-export cleanup in Excel, you can configure Salesforce to insert actual line breaks using a custom label in your formula field. Here’s how it works:

  1. Create a Custom Label: In Salesforce Setup, create a custom label (e.g., line_break). The value of this label should include a visible text value with a new line character between two letters (because Salesforce requires at least some value to be saved). For example, enter something like A\nB (A and B separated by an actual line break).
  2. Reference the Custom Label in a Formula Field: Create a formula field and reference the custom label. Use the formula to replace the two placeholder letters (A and B in this example) with null (empty strings) so that only the line break remains.
  3. Use the Formula Field in Reports: Add this formula field to your reports or list views as needed.
  4. Export to Excel: When you export the report, the field values will now include real line breaks. In Excel, simply select the column and activate Wrap Text—your formatting is preserved just as it appeared in Salesforce.

Why Choose This Method?

  • No Additional Automation Needed: There’s no need for extra flows or post-export Excel formulas.
  • Reusable Across Objects: Since it’s just a formula referencing a custom label, you can deploy the same logic to any object.
  • Faster & Cleaner Exports: Proper formatting with fewer manual steps means less time spent fixing exported files.

Things to Consider

  • Formula fields have character limits, so with extremely large text data you may hit those thresholds more quickly when using this workaround.
  • The workaround is ideal for scenarios where data is regularly exported and line breaks are essential for readability.

By leveraging custom labels holding newline characters and strategic formula references, Salesforce admins and users can ensure clean, readable exported Excel files—no workarounds required post-export!

yellow cloud solvd logo
Testimonials

Our clients say

From my initial call with Spencer through project implementation with John and Evan, my experience with the SOLVD team was excellent. They were quick to understand our business needs, clear when explaining the reasoning behind proposed solutions, transparent when reporting on progress and timeline, and all around enjoyable to work with. Would highly recommend and looking forward to continue working with them in the future!

Veronica Wong Director of Operations at Pathstream

SOLVD was very straight forward with everything needed to complete the project. No surprises, no issues, and cost was aligned with the estimate. They made implementation easy and quick.

Matt Benzaquen Sr Manager, Sales Strategy at Instabug

As a rule, I'm pretty stingy with my recommendations. So it's a pleasure for me to recommend Solvd as a top-flight Salesforce consultancy. Solvd recently led our company's conversion to the Lightning interface and did it on time, on budget and made it easy for me and my team. I know I'll use their services again, and am confident they can do the same for you.

Tim Tuttle CFO at Relevate Health Group

HIGHEST RATED ON SALESFORCE