How to Fix TXT File Misalignment in SharePoint vs Notepad
Question details
Fixed-width text files show properly aligned columns when opened locally in Notepad but appear misaligned when viewed in SharePoint, affecting how Excel macros read the data.

- Product
- SharePoint, Notepad, Excel
- Device & OS
- not provided
- Scenario
- Viewing fixed-width text reports online via SharePoint and processing them using Excel macros.
- Observed behavior
- Columns in the text file shift and lose alignment in the SharePoint online viewer, and Excel macros pull this misaligned formatting instead of the original local layout.
Ensure you have a local backup of your original TXT file and remove any confidential or sensitive data before performing testing or sharing sample files.
Identify and Correct Spacing or Tab Formatting Issues
Determine if the misalignment is caused by tabs instead of spaces, or if it is isolated to specific rows in the SharePoint online viewer.
Differences in how local text editors (like Notepad) and web-based viewers (like SharePoint) render whitespace can cause columns to shift. Web browsers often compress consecutive spaces or use proportional fonts, whereas Notepad uses fixed-width fonts.
Open the file locally in Notepad. Verify if the columns are separated by tabs or spaces. For strict fixed-width alignment on the web, spaces are generally more reliable than tabs.
Create a new, simplified sample .txt file using only spaces for alignment. Upload this sample to SharePoint to test if the online viewer renders the new formatting correctly.
If only specific rows are affected, open the misaligned file in the SharePoint online text editor, manually add or remove spaces to align the affected text, and refresh the page to save changes.

Process the TXT File Locally to Bypass Web Formatting
Download the text file to your local machine before running your Excel macros to ensure the data is read correctly in its original fixed-width format.
Import and Manage Fixed-Width TXT Files in WPS Office
Avoid online formatting glitches by importing your fixed-width text files directly into WPS Spreadsheet. WPS Office accurately parses spaces and columns, ensuring your data remains perfectly aligned without web viewer distortions.
- 1. Open WPS Spreadsheet: Launch WPS Office on your computer and open a new or existing Spreadsheet document.
- 2. Import the TXT File: Go to the 'Data' tab on the top ribbon, select 'Import Data', and choose your local fixed-width .txt file.
- 3. Select Fixed Width option: In the Text Import Wizard, select 'Fixed width' and click 'Next'. You can now manually click to set the column break lines exactly where your data requires them.
- 4. Finish the import: Review the data preview. Once it looks properly aligned, click 'Finish' to import your text data cleanly into spreadsheet cells.

Frequently Asked Questions
Why does my TXT file look perfectly aligned in Notepad but not in SharePoint?
Notepad uses a fixed-width font (like Consolas or Lucida Console) by default, meaning every character and space takes up the exact same width. SharePoint's online viewer may use a proportional font or handle whitespace rendering differently, which causes carefully spaced columns to shift.
How does SharePoint's misalignment affect my Excel macros?
If your Excel macro pulls data directly from the SharePoint web environment and SharePoint alters the underlying spacing or encoding, the macro's fixed-width parsing logic will miscount characters, leading to shifted or corrupted data imports.
Can changing tabs to spaces fix the SharePoint alignment issue?
Yes. Mixing tabs and spaces frequently causes rendering inconsistencies across different text editors and web browsers. Using only spaces for padding in a fixed-width TXT file provides much more predictable alignment in web environments.
How can I prevent the online editor from corrupting my TXT file formatting?
Avoid making direct edits to strict fixed-width data files using web-based text editors. Instead, download the file, make your changes locally using a dedicated text editor like Notepad, and then upload the updated version back to your SharePoint library.




