How to Do Strikethrough in Excel: Methods for Windows & Mac
Table of Contents

Managing data effectively often requires visual cues to signal completion or updates. Whether you are managing a daily task list, tracking inventory, or auditing financial records, learning how to do strikethrough in Excel is an essential skill for staying organized. Excel doesn't feature a strikethrough button on the default Home ribbon, which can be frustrating for new users. However, by using a specific Excel hotkey for strikethrough or accessing the formatting menu, you can quickly cross out information without deleting the underlying data.
- Strikethrough Text in Excel Cells with Basic Methods
- Adding Strikethrough to Your Quick Access Toolbar
- Strikethrough Using Conditional Formatting
- Programmatic Strikethrough with Free Spire.XLS
- FAQs
How to Strikethrough Text in Excel Cells (Basic Methods)
Mastering the basics is the first step toward spreadsheet efficiency. Most users search for how to strikethrough text in an Excel cell because they need a way to mark items as "done" or "obsolete" while keeping the record visible for future reference.
There are two primary ways to achieve this manually: using fast keyboard commands or navigating through the standard formatting tool. Both methods are effective for formatting either an entire cell or just a specific string of text within a cell.
The Ultimate Shortcut for Strikethrough in Excel
Efficiency is key when handling large datasets. If you find yourself frequently needing to do strikethrough in Excel, memorizing the keyboard shortcut will save you hours of clicking through menus over time.
- For Windows Users: The standard shortcut for strikethrough in Excel is Ctrl + 5. Simply select your cell (or highlight text inside the formula bar) and press these keys simultaneously.
- For Mac Users: The most direct strikethrough shortcut in Excel on Mac is Command + Shift + X. If you prefer a more visual approach, you can press Command + 1 to open the Format Cells dialog, navigate to the Font tab, and manually check the "Strikethrough" box.
Note: These shortcuts are toggles. If you press them a second time on the same cell, the strikethrough effect will be removed immediately.
Manual Method: Using the Format Cells Tool
If you aren't a fan of keyboard shortcuts, the classic Format Cells menu offers a visual way to apply styles. This method is often considered the most reliable way to cross out text in Excel because it allows you to preview the font changes before applying them to your spreadsheet.
Step-by-Step Instructions:
- Right-click on the cell or the specific text you wish to format.
- Select Format Cells from the context menu (or press Ctrl + 1).
- Navigate to the Font tab in the popup window.
- Under the Effects section, check the box labeled Strikethrough.
- Click OK to apply the change.

Tip: If you are looking to further polish your cell's appearance, you might also want to learn how to rotate text in Excel to create professional headers.
Advanced: Adding Strikethrough to Your Quick Access Toolbar
For those who perform this action dozens of times a day, even a shortcut might feel repetitive. You can actually customize your workspace to include a dedicated button for this function, making it easier than ever to do strikethrough in Excel with a single click.
Step-by-Step Instructions:
- Click the small drop-down arrow on the Quick Access Toolbar (located at the very top of your Excel window).
- Select More Commands from the list.
- Under "Choose commands from," select All Commands.
- Scroll down to find Strikethrough and click the Add >> button to move it to your toolbar.
- Click OK to save your changes.
Adding these frequently used buttons to your ribbon saves time. Just as you’ve added a strikethrough button, mastering different ways to wrap text will help you keep your headers and data neat with minimal clicks.
Dynamic Strikethrough: Using Conditional Formatting
Sometimes, you want Excel to do the heavy lifting for you. By using conditional formatting, you can set up a rule that automatically applies a strikethrough text in Excel cell style based on the value of another cell.
Step-by-Step Instructions:
- Highlight the cells you want to be automatically crossed out (e.g., task names in Column A).
- Go to the Home tab and click Conditional Formatting > New Rule.
- Select Use a formula to determine which cells to format.
- In the formula box, enter a rule like
=$B2="Done"(assuming Column B contains your status). - Click the Format button, go to the Font tab, and check the Strikethrough box.
- Click OK on both windows to apply the rule.

Now, whenever you type "Done" in Column B, the corresponding task in Column A will be instantly struck through. This is the smartest way to strikethrough text in an Excel cell without lifting a finger once the setup is complete.
Programmatic Strikethrough: Using Free Spire.XLS for Python
For developers and data analysts, manual clicking is not an option when dealing with thousands of generated reports. In these cases, using a robust library like Free Spire.XLS allows you to automate how to do strikethrough in Excel through code.
Using Free Spire.XLS, you can programmatically define styles for specific ranges. This is particularly useful for automated financial auditing or generating before and after reports where changes need to be visually highlighted.
from spire.xls import *
from spire.xls.common import *
# Create a Workbook instance and load an Excel file
workbook = Workbook()
workbook.LoadFromFile("/input/sales report.xlsx")
# Get a worksheet
sheet = workbook.Worksheets[0]
# Apply strikethrough to specific cells
sheet.Range["H3"].Style.Font.IsStrikethrough = True
sheet.Range["H10"].Style.Font.IsStrikethrough = True
# Save the modified Excel file
workbook.SaveToFile("/output/Updated_Tasks.xlsx", ExcelVersion.Version2016)
workbook.Dispose()
The preview of the output Excel file:

This approach allows you to apply strikethrough formatting programmatically across large datasets, ensuring consistency across enterprise-level documentation without human error.
Furthermore, Free Spire.XLS can be seamlessly combined with conditional formatting logic. For instance, in the inventory file shown above, you can write code to automatically apply a strikethrough to any cell in Column H whenever its value is set to "Out of Stock". This ensures your data remains dynamic and visually intuitive without any manual intervention.
Conclusion
Mastering how to do strikethrough in Excel is a small but powerful way to improve your data visualization and project management. Whether you prefer the speed of a shortcut for strikethrough in Excel, the precision of the Format Cells menu, or the automation power of Free Spire.XLS, there is a solution tailored to your specific workflow. By incorporating these techniques, you can transform a static spreadsheet into a functional, easy-to-read dashboard.
FAQs about Strikethrough in Excel
Q1: What is the shortcut for strikethrough in Excel?
A: Use Ctrl + 5 on Windows or Command + Shift + X on Mac. It’s a toggle, so pressing it again removes the effect.
Q2: How to strikethrough a whole row in Excel?
A: Use Conditional Formatting. Select your range and use a formula like =$B2="Done". The $ ensures the entire row is crossed out based on one cell's value.
Q3: What is the Alt code for strikethrough?
A: There is no direct Alt code, but you can use the sequence Alt > H > 4 on Windows to apply it via the ribbon menu.
Q4: Can I use Ctrl + E for strikethrough?
A: Ctrl + E is for Flash Fill. For strikethrough, you need to use Ctrl + 5.
Also Read
Count Colored Cells in Excel: 3 Easy Ways (Manual/Automation)
Table of Contents

When it comes to data management, color is often more than just a visual aid. It represents a vital layer of information. Whether you are highlighting overdue invoices in red or marking completed projects in green, these visual cues help us navigate complex datasets at a glance. However, a common frustration arises when you need to turn those colors into numbers: Excel lacks a native, one-click function to count colored cells in Excel. In this guide, we will explore three effective methods, ranging from simple manual tricks to advanced automation with Python, to help you master this essential task.
- Counting Highlighted Excel Cells Without VBA
- Count Colored Excel Cells Using Python
- Handling Conditional Formatting
Method 1: Counting Highlighted Excel Cells Without VBA
If you are dealing with a one-off report or a small dataset, you might prefer a solution that uses only the standard Excel interface. Fortunately, you can leverage built-in features to achieve accurate results without touching a single line of VBA. There are two primary manual ways to tackle this: the Filter method for dynamic counting and the Find method for a quick tally.
A. The Filter and SUBTOTAL Method
This is the most reliable manual technique for counting Excel cells by color in dynamic datasets. Unlike the standard COUNT function, SUBTOTAL can be configured to ignore hidden rows, making it the perfect partner for filters.
- Step 1: In a cell outside your data range, insert the formula
=SUBTOTAL(103, A2:A100). The code103tells Excel to count non-empty visible cells. - Step 2: Select your header row and press "Ctrl + Shift + L" to enable filters.
- Step 3: Click the filter dropdown on your colored column, select Filter by Color, and choose your target shade.

- Step 4: The formula will automatically update to show only the count of the filtered colored cells.

B. The Find and Select Method
If you just need a quick count without setting up formulas, the Find tool is surprisingly effective. This method scans the sheet for a specific format and tells you how many instances it found in the status bar.
- Step 1: Press Ctrl + F to open the Find and Replace dialog and click Options.
- Step 2: Click the small arrow next to the Format button and select Clear Find Format. This is a critical step to ensure no previous search settings interfere with your current search.
- Step 3: Click the Format... button.
- Step 4: In the popup dialog, navigate to the Fill tab.
- Step 5: Either manually select your target color or use Choose Format From Cell. If you use the sampler, quickly check the Font, Border, and Number tabs to ensure they haven't been automatically filled; if they have, clear those specific settings.

- Step 6: Ensure the Find what text box is completely empty.

- Step 7: Click Find All. You will see the total count at the bottom of the window.

Method 2: Count Colored Excel Cells Using Python (Static Fill)
While manual filters work for quick checks, they fall short when you need to process hundreds of files. This is where Free Spire.XLS for Python shines, allowing you to programmatically count highlighted cells in Excel by accessing the style properties of every cell. Since manually filled colors are stored as static attributes, the most robust approach for counting is to sample the target color from an existing reference cell.
This sampling technique ensures that colored cells in Excel are counted accurately, even if the file uses complex theme colors or custom RGB tints that are hard to define manually.
- Step 1: Load your workbook and access the specific worksheet using index.
- Step 2: Sample the ARGB value from a reference cell (e.g., B3) to define your target color.
- Step 3: Iterate through the target range to compare each cell's style and increment your count.
The following Python example demonstrates how to sample a reference cell's color to count all matching cells within a range:
from spire.xls import *
from spire.xls.common import *
# Create a Workbook object
workbook = Workbook()
# Load an Excel file
workbook.LoadFromFile(r"/input/Population.xlsx")
# Get the third worksheet
sheet = workbook.Worksheets[2]
# Sample the ARGB value from a known colored cell (B3) to ensure a perfect match
target_argb = sheet.Range["B3"].Style.Color.ToArgb()
count = 0
# Iterate through the specific range to count colored cells
for cell in sheet.Range["B1:E12"]:
if cell.Style.Color.ToArgb() == target_argb:
count += 1
# Print the result
print(f"Total colored cells count: {count}")
workbook.Dispose()
The counting result:

Method 3: Handling Conditional Formatting via Logic
Static colors are straightforward, but conditional formatting is a different beast entirely. Since the color is generated dynamically based on rules, the cell’s underlying style property often remains empty. The color you see is merely a rendering layer.
To count Excel cells colored by conditional formatting, the most professional approach is to sync your logic. Instead of detecting the visual output of colored cells, you should count the underlying data that triggers the rule. This method is faster and more robust, as it bypasses the apparent rendering and prevents errors caused by varying Excel versions or themes.
- Step 1: Define your conditional formatting rule using Free Spire.XLS.
- Step 2: Use the same logical condition in your counting loop.
The following example demonstrates how to count highlighted cells in Excel based on their conditional formatting logic:
from spire.xls import *
from spire.xls.common import *
# Initialize workbook and load the source file
workbook = Workbook()
workbook.LoadFromFile(r"/input/Population.xlsx")
# Get the third worksheet
sheet = workbook.Worksheets[2]
# Define the target range for conditional formatting
data_range = sheet.Range["D3:D12"]
# Apply conditional formatting rule: Highlight cells > 10 in Red
cf = sheet.ConditionalFormats.Add()
cf.AddRange(data_range)
condition = cf.AddCondition()
condition.FormatType = ConditionalFormatType.CellValue
condition.Operator = ComparisonOperatorType.Greater
condition.FirstFormula = "10"
condition.BackColor = Color.get_Red()
# Perform logical counting synchronized with the formatting rule
count = 0
for cell in data_range:
if cell.NumberValue > 10:
count += 1
print(f"Total cells matching condition (> 10): {count}")
# Save the stylized result
#workbook.SaveToFile(r"/output/Conditional_Red_Result.xlsx", ExcelVersion.Version2016)
workbook.Dispose()
The result of counting colored cells in Excel using conditional format:

Notice: This method is ideal when the conditional formatting rules are already known. While it is technically possible to reverse-engineer underlying Excel rules via ConditionalFormats, the varying storage mechanisms across different file versions make 'Logic Sync' the most robust and high-performance approach. By bypassing complex API calls, this practice guarantees accuracy in your results.
Conclusion
Mastering how to count colored cells in Excel helps bridge visual formatting and reliable data analysis. For simple scenarios, built-in filters may be enough; for complex workflows, logic-based solutions like Free Spire.XLS provide better accuracy and scalability. By shifting from manual color counting to rule-driven reporting, your spreadsheets become a more dependable source of truth.
Also Read
How to Lock Excel Cells: Manual & Python Automation Guide

Protecting your data from accidental changes is a fundamental skill for anyone managing sensitive information. Whether you are building a financial model or a shared tracking sheet, knowing how to lock Excel cells ensures that your core data and complex calculations remain intact. This guide will walk you through the standard manual methods and advanced Python techniques to secure your spreadsheets effectively, helping you understand how to lock a cell in Excel with precision.
- Locking Cells in MS Excel
- Locking Cells in Excel via Spire.XLS for Python
- Lock Cells with Formula with Spire.XLS
- Troubleshooting & Tips
1. The Manual Method: Locking Cells in MS Excel
For most daily tasks, the built-in interface in Microsoft Excel is the quickest way to safeguard your work. It is designed for accessibility, allowing users to toggle protection settings through a few clicks in the ribbon. Understanding the workflow is essential, as it establishes the core logic of Excel's security layers.
1.1 Lock All Cells in a Worksheet
By default, every cell in an Excel sheet is technically marked as "Locked," but this property remains dormant until worksheet protection is activated. This global approach is ideal for creating read-only distributions where no data should be modified. To apply a total lock, follow these steps:
-
Open your Excel workbook and navigate to the Review tab on the top ribbon.
-
Click the Protect Sheet button.
-
In the pop-up window, enter an optional password and ensure the box "Protect worksheet and contents of locked cells" is checked.
- Click OK and confirm your password. This is the simplest way when you want to lock a cell in Excel for a secure, final document.

1.2 How to Lock Certain Cells in Excel
In many professional scenarios, you need users to enter data in specific cells while keeping headers and core values protected. This requires reversing the default settings so that only a chosen selection remains restricted. This selective approach is the most common answer to locking certain cells in Excel without hindering user collaboration:
-
Select the entire worksheet (click the triangle in the top-left corner or press Ctrl + A).
-
Right-click any cell, select Format Cells, go to the Protection tab, and uncheck Locked. (All cells are now editable).
-
Highlight only the specific cells or ranges you wish to protect.
-
Right-click the selection, return to Format Cells > Protection, and check the Locked box.
-
Go to the Review tab and click Protect Sheet to activate these restrictions.

1.3 How to Lock the Cell in Excel with Formula
Formulas are the brain of your spreadsheet. After you insert formulas into Excel, protecting them from accidental overwrites becomes essential for maintaining long-term accuracy. Instead of checking for every calculation manually, Excel offers a specialized tool to identify them instantly. To lock the cell in Excel with a formula ensures your logic remains tamper-proof:
-
Select all cells in your worksheet, go to Format Cells > Protection, and uncheck Locked so the sheet starts as fully editable.
-
On the Home tab, click Find & Select in the Editing group and choose Go To Special.
- Select the Formulas radio button and click OK; Excel will automatically highlight every cell containing a calculation.
-
With the formulas still highlighted, right-click one of them, choose Format Cells, and check the Locked box.
-
Finally, navigate to the Review tab and select Protect Sheet to lock down your calculations while leaving raw data cells open for input.


2. Locking Cells in Excel via Free Spire.XLS for Python
Manual clicking quickly becomes a liability when managing hundreds of files or dynamic reports. By using a Python library like Free Spire.XLS, you can implement robust protection using either specific coordinates or the allocated range to target only cells containing actual content. This programmatic approach is perfect for developers who need to enforce data integrity across massive datasets. To achieve a professional lock of certain cells in Excel automatically, you can utilize the following script, which offers the flexibility to protect specific coordinates or the entire used area via simple comment toggles:
from spire.xls import *
from spire.xls.common import *
# Specify the file path
inputFile = "/input/sample.xlsx"
outputFile = "/output/LockAllUsedCells.xlsx"
# Create a Workbook instance and load the file
workbook = Workbook()
workbook.LoadFromFile(inputFile)
# Get the first worksheet
sheet = workbook.Worksheets[0]
# Use AllocatedRange to get all cells that contain data or formatting
usedRange = sheet.AllocatedRange
# Lock a specific cell in the sheet
#sheet.Range["A1"].Text = "Locked"
#sheet.Range["A1"].Style.Locked = True
# Lock a specific range of cells in the sheet
#sheet.Range["C1:E3"].Text = "Locked"
#sheet.Range["C1:E3"].Style.Locked = True
# Set the range to locked
usedRange.Style.Locked = True
# Set sheet protection for locking
sheet.Protect("123456", SheetProtectionType.All)
# Save the result file
workbook.SaveToFile(outputFile, ExcelVersion.Version2013)
workbook.Dispose()
The preview of the Excel file modified with Free Spire.XLS for Python:

3. How to Lock a Cell in Excel with Formula Using Free Spire.XLS
Static ranges are easy to protect, but relying on fixed addresses can lead to security gaps if your data structure evolves or expands. The most efficient solution is to programmatically scan the workbook using the HasFormula property, which identifies calculations regardless of their position.
This API-driven approach effectively replicates the manual "Go To Special" feature with speed and repeatability, offering a professional way to lock cells in Excel with a formula. To implement this dynamic protection, you can use the following script to iterate through the used area and secure every formula automatically:
from spire.xls import *
from spire.xls.common import *
# Define input and output paths
inputFile = "/input/sample.xlsx"
outputFile = "/output/LockFormulaCells.xlsx"
# Create a Workbook instance and load the file
workbook = Workbook()
workbook.LoadFromFile(inputFile)
# Get the first worksheet
sheet = workbook.Worksheets[0]
# Iterate through all used cells in the worksheet
for cell in sheet.AllocatedRange:
# Check if the cell contains a formula
if cell.HasFormula:
# Lock the cell if it contains a formula
cell.Style.Locked = True
else:
# Unlock the cell if it's just data, so users can still edit it
cell.Style.Locked = False
# Apply protection with a password to make the locking effective
sheet.Protect("123456", SheetProtectionType.All)
# Save the result file
workbook.SaveToFile(outputFile, ExcelVersion.Version2013)
workbook.Dispose()
4. Troubleshooting & Tips
To ensure your protection works flawlessly, keep these essential tips in mind for both manual and programmatic methods:
Common Pitfalls in MS Excel
-
The "Two-Step" Rule: To activate protection, always perform both: (1) Check the "Locked" box in Format Cells and (2) Click "Protect Sheet" in the Review tab.
-
Default Locking: Remember that Excel locks all cells by default. If you want to lock only a few, you must first select the whole sheet and uncheck "Locked" before targeting your specific cells.
-
Overlapping Permissions: If you allow "Select locked cells" in the Protection menu, users can still click them, which sometimes leads to confusion about whether the lock is active.
Performance & Logic in Python
-
Activation: Just like the manual method,
Style.Locked = Trueonly flags a cell. You must callWorksheet.Protect()in your code to turn the key. -
Optimization: Use
Worksheet.AllocatedRangeto ensure your script only processes cells that actually contain data.
Password Security
-
Unlocking Difficulty: Free Spire.XLS and Excel use strong encryption. If you set a password, store it safely; recovering a protected sheet without it is nearly impossible.
-
Read-Only vs. Locked: Locking cells prevents editing, but if you need to hide formulas entirely, remember to check the "Hidden" box in the "Format Cells" menu as well.
Conclusion
Mastering how to lock Excel cells is a vital step in maintaining the security and professionalism of your digital workspace. Whether you prefer the visual simplicity of the MS Excel ribbon for one-off tasks or the scalable power of Free Spire.XLS for Python automation, the core principles remain the same: unlock your inputs, lock your logic, and always enable sheet protection. If you are ready to streamline your data management, start by applying these protection strategies to your most critical workbooks today.
How to Integrate Spire.OfficeJS into JavaScript
Spire.OfficeJS is a powerful front-end JavaScript library that enables users to edit, preview, and process Office documents directly in a web browser—without plugins and without installing local tools such as Microsoft Office or WPS.
This article explains how to use Spire.OfficeJS in a native JavaScript environment.
Spire.OfficeJS consists of four modules:
- Spire.WordJS: Provides preview and editing capabilities for Word documents, with full compatibility with Microsoft Word and WPS formats, such as .doc, .docx, .wps, and .wpt.
- Spire.ExcelJS: Enables preview and editing of Excel documents, including formats such as .xls, .xlsx, .et, and .ett.
- Spire.PresentationJS: Supports preview and editing of PowerPoint documents, including .ppt and .pptx.
- Spire.PDFJS: Provides preview functionality for PDF documents.
Table of Contents
Preparation
Spire.OfficeJS is powered by a web service. To use it in a native JavaScript environment, you must first start the web service.
The service is launched using scripts included in the product package, with the default service port set to 8001.
Step 1. Download and Extract the Installation Package
Download the Spire.OfficeJS package for your operating system, and extract it to a local directory.
Step 2. Start the Web Service
- Windows
In the extracted product directory, run the run_servers.bat file. The terminal output will be similar to the following:

Note: Port 3000 is used by the sample document management system. By default, you can access it in a browser at localhost:3000 or 127.0.0.1:3000 for testing.
- Linux (x86_64)
Run the run_servers.sh file in the extracted product directory using the command sh run_servers.sh start (to stop the service, use sh run_servers.sh stop; to restart the service, use sh run_servers.sh restart).
The terminal output is shown below:

Step 3. Configure the Service Address
By default, the service uses 127.0.0.1. You can modify the baseUrl value in the example\config\default.json file to a domain name or an actual IP address, so that the service can be accessed via a domain or IP address.
After making the change, restart the service for the configuration to take effect.

Now, the client can access the sample system using the configured IP address or domain name, for example: 192.168.3.127:3000

JavaScript Integration Examples:
- Browser Preview Integration (HTML):

Script file:
To help you get started quickly, you can download the complete HTML example file using the link below and open it directly in your browser:
Demo Download
- Parameter Description:
| Parameter | Example Description | Value | ||
| fileAttrs | File Configuration Object | |||
| fileInfo | File Information Object | |||
| name | File Name Optional | Optional | ||
| ext | Document Name | docx,xlsx,pptx | ||
| primary | Document Unique Identifier | Optional | ||
| creator | Document Creator | Optional | ||
| createTime | Document Creation Time | Optional | ||
| sourceUrl | Document URL | Required. Must be accessible and have the appropriate access permissions. | ||
| createUrl | Template Document URL | Optional | ||
| user | User Configuration Object | |||
| id | User ID | Optional | ||
| name | User Name | Optional | ||
| editorAttrs | Editor Configuration Object | |||
| editorMode | Edit Mode Optional. Accepts 'edit' (edit) or 'view' (view). Default is 'edit'. | Optional. Accepts 'edit' (edit) or 'view' (view). Default is 'edit'. | ||
| editorWidth | Width | Optional. Default value is 100%. | ||
| editorHeight | Height | Optional. Default value is 100%. | ||
| editorType | Editor Type | Optional. If not specified, the editor type is determined automatically based on the file type. Must be set to document, spreadsheet, or presentation. | ||
| platform | Editor Platform Type | Required. Accepts 'desktop' (desktop view), 'mobile' (mobile view), or 'embedded' (embedded view). Must be set to one of: desktop, mobile, or embedded. | ||
| viewLanguage | UI Language | Optional. Accepts "en" or "zh". If not specified, the browser’s default language is used. | ||
| isReadOnly | Read-Only Mode | Default is false, allowing the document to be edited. When set to true, the document is read-only. | ||
| canChat | Chat Enabled | Default is true. When set to false, chat is disabled. | ||
| canComment | Comments Enabled | Default is true. When set to false, comments are disabled. | ||
| canReview | Track Changes Enabled | Default is true. When set to false, track changes is disabled. | ||
| canDownload | Download Allowed | Default is true, allowing downloads. When set to false, downloading is not allowed. | ||
| canEdit | Edit Allowed | Default is true, allowing editing. When set to false, editing is not allowed. | ||
| canForcesave | Force Save Enabled | Default is true. When set to false, force save is disabled. | ||
| embedded | Embedded View Configuration Object | Includes saveUrl, embedUrl, shareUrl, and toolbarDocked, used to control saving, sharing, and toolbar display in embedded mode. | ||
| saveUrl | Embedded Document Save URL | Default is empty. Can be set to a URL used to save edited content. | ||
| embedUrl | Embedded Document Access URL | Default is empty. Can be set to a URL used to open the document directly. | ||
| shareUrl | Embedded Document Share URL | Default is empty. Can be set to a URL used to share the document. | ||
| toolbarDocked | Toolbar Dock Position | Default is "top". Accepts "top" or "bottom". | ||
| events | Events | |||
| plugins | Editor Plugin Configuration Object | Default is empty. Used to extend editor functionality. | ||
| pluginsData | Plugin Data Array | Default is empty. Plugins can be added as needed. | ||
| useWebAssemblyDoc | Enable WebAssembly for Word Documents | Default is true, allowing Word documents to be processed in the browser. When set to false, WebAssembly support is disabled. | ||
| spireDocJsLicense | Word WebAssembly License File URL | Default is empty. Used to activate the WebAssembly functionality. | ||
| useWebAssemblyExcel | Enable WebAssembly for Excel Documents | Default is true, allowing Excel documents to be processed in the browser. When set to false, WebAssembly support is disabled. | ||
| spireXlsJsLicense | Excel WebAssembly License File URL | Default is empty. Used to activate the WebAssembly functionality. | ||
| useWebAssemblyPpt | Enable WebAssembly for PowerPoint Documents | Default is true, allowing PowerPoint documents to be processed in the browser. When set to false, WebAssembly support is disabled. | ||
| spirePresentationJsLicense | PowerPoint WebAssembly License File URL | Default is empty. Used to activate the WebAssembly functionality. | ||
| useWebAssemblyPdf | Enable WebAssembly for PDF Documents | Default is true, allowing PDF documents to be processed in the browser. When set to false, WebAssembly support is disabled. | ||
| spirePdfJsLicense | PDF WebAssembly License File | Default is empty. Used to activate the WebAssembly functionality. | ||
| spireOfficeJsLicense | OfficeJS License File | Default is empty. Used to activate all online document editing features. | ||
| serverless | Serverless Mode Configuration Object | Includes useServerless, baseUrl, and fileData, allowing the front end to upload, edit, and download documents directly. | ||
| useSeverless | Enable Serverless Mode | Default is true. When enabled, the front end can operate on documents directly. When set to false, a server-side service is required. | ||
| baseUrl | Service URL in Serverless Mode | Default is empty. Must be set to the deployed server IP address and port. | ||
| fileData | Document Data | Default is empty. Stores the uploaded file data on the front end and is used to initialize the editor. | ||
Note: Applying a license removes the default watermark and unlocks all features. If you need a license file, please feel free to contact us at any time.
Frequently Asked Questions
During the deployment and integration of Spire.OfficeJS, you may encounter certain issues. The table below lists some common problems along with their solutions for your reference. If you have any additional questions, please contact our technical support team.
| Issue | Cause | Solution |
|---|---|---|
| Unable to access the service in the browser | Service not started / Required ports not open | Verify that the service is running and ensure ports 3000 and 8001 are open |
| Page loads but displays a blank screen | Browser cache contains outdated resources | Clear the browser cache or reopen the page in private/incognito mode |
| JavaScript file fails to load | Incorrect IP address or port | Check whether the SpireCloudEditor.js script URL is correct |
| File upload fails | baseUrl is not configured with the actual deployment address |
Update the configuration file and restart the service |
| Unable to execute the script on Linux | Insufficient script permissions | Run chmod +x run_servers.sh to grant execute permissions |
Summary
At this point, you have successfully completed the deployment and integration of Spire.OfficeJS. Your system can now view and edit documents online directly in the browser, without requiring client-side installations or additional development environments.
If you would like to explore more advanced usage scenarios or learn how to integrate Spire.OfficeJS into different types of applications, please refer to the related documentation or contact our team for further guidance.
How to Count Cells with Text in Excel: A Complete Guide

Managing massive spreadsheets often feels like looking for a needle in a haystack. Whether you are cleaning raw data or preparing a financial summary, one of the most fundamental tasks is knowing how to count cells with text in Excel. While it sounds simple, the presence of numbers, hidden spaces, and formula-generated empty strings can easily lead to inaccurate results. In this guide, we will break down the most reliable Excel formulas for text counting and show you how to automate these solutions effortlessly.
- Essential Excel Formulas to Count Cells with Text
- Count Cells with Text in Microsoft Excel
- Count Cells with Text in Excel Automatically
- Dealing with Edge Cases: Common Pitfalls
Core Concepts: Essential Excel Formulas to Count Cells with Text
To master data validation, you first need to understand the mechanics of the COUNTIF function. It is the most intuitive tool when it comes to counting cells with text in an Excel file, but its true power lies in how you define your criteria.
The Foundation: Using COUNTIF for Quick Counting
The basic syntax, =COUNTIF(range, criteria), allows you to scan a dataset for specific patterns. When dealing with generic text, we use wildcards to tell Excel exactly what qualifies as "content."
Four Common Scenarios for Counting Text
Excel files often contain multiple types of data, so you may need to use one or more of the following four specialized approaches:
Scenario 1: The Standard Way (General Text)
- Formula:
=COUNTIF(range, "*") - Analysis: This is the most common Excel formula to count cells with text. The asterisk (*) acts as a wildcard that matches any text string, so only text values are counted, for example, cells containing "Apple", "Banana", or "Text123" will be included, while cells with only numbers are excluded.
Scenario 2: The Data Cleaning Way (Excluding Pseudo-Blanks)
- Formula:
=COUNTIFS(range, "*", range, "<> ") - Analysis: Some cells may appear empty but actually contain a single space character. By combining multiple criteria with
COUNTIFS, this formula counts cells that contain text while excluding values that are exactly one space. For example, entries like "Apple" or "Text123" are included, while cells containing " " are ignored. However, this approach does not exclude cells that contain two or more spaces, so it can be combined with other formulas for more precise results.
Scenario 3: The Technical Way (Strict Text-Only)
- Formula:
=SUMPRODUCT(--ISTEXT(range)) - Analysis: When a worksheet contains a mix of dates, error values (#N/A), and logical values (TRUE/FALSE), ISTEXT provides a strict way to identify text. It checks the underlying data type rather than the displayed characters, so values like "Apple" or "Text123" are counted, while dates, booleans, and errors are excluded.
Scenario 4: The Advanced Way (Specific Substrings)
- Formula:
=COUNTIF(range, "*keyword*") - Analysis: This approach is useful for log analysis or keyword tagging. By using wildcards on both sides, the formula counts cells that contain a specific substring anywhere within the text, for example, values like "error_404" or "login_error" are included when searching for "error".
How to Count Cells with Text in Microsoft Excel
Using these formulas directly in Excel offers several practical advantages. Most users already have Excel installed and are familiar with its interface, making it easy to enter formulas, navigate sheets, and quickly validate results. Applying Conditional Formatting can serve as a visual sanity check, helping you verify which cells meet the text criteria.
Steps to Count Text in Excel Using COUNTIF
-
Select a range, for example, B1:B10.
-
Enter the appropriate formula in any blank cell:
=COUNTIF(B1:B10, "*")=COUNTIF(B1:B10, "*keyword*")(optional)=COUNTIFS(B1:B10, "*", B1:B10, "<> ")(optional)
-
Press Enter and the cell shows the counting result.

Tip: If you want to see which cells are counted, you can use conditional formatting with a formula like =ISTEXT(B1) to highlight the text cells. This makes it easy to visually identify the counted entries.
How to Count Cells with Text in Excel Automatically Using Free Spire.XLS
Manual formatting is fine for one-off tasks, but what if you have 500 workbooks? This is where Free Spire.XLS shines. It allows you to inject these professional text counting logics directly into your Excel files programmatically.
Why Automate?
Automation eliminates human error and saves hours of repetitive clicking. With Free Spire.XLS, you can apply complex count formulas in Excel cells with text logic across thousands of rows in seconds.
Step-by-Step Implementation (Python Example)
Free Spire.XLS makes it easy to apply COUNTIF formulas programmatically. In this example, we count the number of text cells in a specified range and write the result directly to the worksheet.
from spire.xls import *
# Create a Workbook and load an Excel file
workbook = Workbook()
workbook.LoadFromFile("/sample.xlsx")
# Get the first worksheet
sheet = workbook.Worksheets[0]
# Specify the cell range for counting
source_range = "B1:B10"
# Count cells with text using COUNTIF
sheet.Range["D1"].Text = "Total Text Cells:"
sheet.Range["E1"].Formula = f'=COUNTIF({source_range}, "*")'
# Save the modified Excel file
workbook.SaveToFile("/Text_Count_Simple.xlsx", ExcelVersion.Version2016)
workbook.Dispose()
Here's the counting result:

Dealing with Edge Cases: Common Pitfalls
Even experienced Excel users can get tripped up by subtle data quirks. When counting text with COUNTIF, keep the following points in mind:
- Empty Strings:
Cells containing formulas like ="" return empty strings rather than true blanks. Although COUNTIF(range, "*") does not count these cells, they can still cause confusion when visually inspecting data or when using functions such as COUNTA. If necessary, LEN(A2)>0 can be used to explicitly test for non-empty text.
- Hidden Characters:
Data copied from web pages or external systems often includes non-breaking spaces (CHAR(160)), which are not removed by TRIM(). In such cases, combining SUBSTITUTE(A2, CHAR(160), "") with TRIM() helps ensure that only meaningful text is counted. You may also find converting numbers to text in Excel useful when preparing data for consistent counting.
- Incorrect Ranges:
Miscounted results are often caused by selecting the wrong cell range rather than using an incorrect formula. Always double-check the starting and ending cells, especially when comparing manual Excel results with automated outputs.
- Performance:
Using built-in Excel formulas such as COUNTIF allows Free Spire.XLS to rely on Excel’s native formula engine for calculation. This approach is significantly more efficient than iterating through each cell in code to evaluate its value, particularly when working with large worksheets.
Conclusion
Learning how to count cells with text in Excel is a small skill that yields massive dividends in data accuracy. By moving from manual formulas to Free Spire.XLS automation, you transform a tedious chore into a scalable, error-free workflow. Whether you're managing simple lists or complex databases, these tools ensure your insights are always based on clean, well-categorized data.
Ready to take your spreadsheet game to the next level? Try Free Spire.XLS and start automating your data validation with ease!
Also Read
How to Convert RTF to PDF Online and Offline (3 Proven Ways)

Rich Text Format (RTF) is a versatile file type for cross-platform sharing, but when it comes to professional presentation and document security, the PDF format is the industry standard. Whether you are a casual user looking for a quick fix or a developer needing a long-term solution, knowing how to convert RTF to PDF efficiently can save you significant time and effort. In this guide, we will explore three distinct methods, ranging from online tools and desktop software to automated Python scripts, to make your documents remain polished and safe.
- Online RTF to PDF Converters
- Microsoft Word Save RTF as PDF
- Automated Conversion with Free Spire.Doc for Python
- Compare the Three Methods
1. The Quickest Choice: Online RTF to PDF Converters
If you only have a single document and don't want to install new software, an online RTF-to-PDF converter is the top choice. These platforms are designed for speed and accessibility, allowing you to transfer RTF to PDF directly from your web browser. While they require an internet connection, they are incredibly user-friendly for non-technical tasks.
Option A: Convertio (A Multi-Format Hub)
Convertio is a robust all-in-one conversion site. It is ideal for users who handle various file types and want a clean, ad-free interface.

- Step 1: Visit the Convertio website and click "Choose Files" to upload your RTF document.
- Step 2: Choose PDF as the output format.
- Step 3: Click "Convert" to convert the RTF file to PDF, and then download the final PDF.
Option B: CLOUDXDOCS (Document-Centric AI Platform)
CLOUDXDOCS is a specialized hub focusing on professional document formats like Word, PDF, and RTF. Unlike general converters, it features built-in AI tools that allow you to refine or edit your content immediately after converting from RTF to PDF.

- Step 1: Navigate to the "Converter" menu on the homepage and select "RTF > PDF."
- Step 2: Upload your RTF document; the platform will automatically begin the conversion process.
- Step 3: Once finished, click "View" to preview the results or "Download" to save the PDF to your local device.
2. The Native Method: Microsoft Word "Save As" PDF
For users who already have office productivity suites installed, utilizing desktop software is the most secure and reliable way to handle documents. This method doesn't require an internet connection and provides high-quality results for maintaining complex formatting. Learning how to save RTF as PDF natively helps to preserve your fonts and margins to look the same.
Microsoft Word remains the most popular tool for this task because it handles RTF encoding natively, minimizing the risk of garbled text that sometimes occurs with low-quality converters.
How to convert an RTF file to PDF using MS Word:
- Step 1: Right-click your RTF file and select Open with > Word.
- Step 2: Once the document is open, go to the File menu in the top-left corner.
- Step 3: Go to Save As and choose PDF from the file type dropdown menu.
- Step 4: Choose your destination folder and click Save.

While MS Word is great for quick PDF exports, you might also want to transfer your files to a standard Word format permanently. If you're looking for a dedicated way to convert RTF to Word, the process is equally straightforward.
3. The Developer's Solution: Free Spire.Doc for Python
When you need to process hundreds of files or integrate document conversion into a software project, manual methods are no longer practical. Free Spire.Doc for Python offers a professional library to save RTF as PDF programmatically. Unlike the previous methods, this approach allows for total automation without needing Microsoft Word installed on your system.

This library is particularly powerful because it gives developers granular control over the RTF-to-PDF conversion process, making it the preferred choice for high-volume business environments.
How to convert RTF to PDF via Python:
- Step 1: Open your terminal and run:
pip install Spire.Doc.Freeto install the library. - Step 2: Create a Document object and load an RTF file.
- Step 3: Save the RTF file as a PDF by calling the Document.SaveToFile() method.
Here's the code example:
from spire.doc import *
from spire.doc.common import *
inputFile = "sample.rtf"
outputFile = "RtfToPDF.pdf"
# Create a Document object
doc = Document()
# Load an RTF file from disk
doc.LoadFromFile(inputFile)
# Save the RTF file as a PDF file
doc.SaveToFile(outputFile, FileFormat.PDF)
doc.Close()
Comparison: Which Method Should You Use
To help you decide which approach fits your workflow, here is a quick comparison of the three methods discussed:
| Feature | Online Converters (CLOUDXDOCS/Convertio) | Microsoft Word | Free Spire.Doc for Python |
|---|---|---|---|
| Best For | Casual users & one-off tasks | Formal, manual editing | Developers & Automation |
| Setup Required | None (Browser-based) | Software installation | Python environment & library |
| Privacy Level | Files processed on cloud servers | High (Local processing) | High (Local/Server processing) |
| Batch Processing | Limited/Manual | No (One by one) | Yes (Fully automated) |
| Internet Required | Yes | No | No |
| Cost | Free (often with daily limits) | Requires Office license | Free |
Conclusion
Choosing the right approach depends entirely on your specific needs. Online RTF to PDF converters are perfect for one-off tasks, while Microsoft Word is the go-to for offline, high-fidelity editing. However, for those looking for an automated way to save RTF as PDF within a workflow, Free Spire.Doc for Python provides a sophisticated and efficient solution. By understanding how to convert RTF to PDF through these different methods, you can ensure that your documents are always professional, portable, and perfectly formatted for your target audience.
Also Read
PNG to Word Converter: Top 5 Ways to Convert PNG to Word
Turning a PNG image into an editable Word document sounds simple, but many people quickly discover that it’s not as straightforward as expected. Whether you’re dealing with scanned contracts, screenshots of reports, or image-based invoices, directly copying content from a PNG file rarely works.
This article compares five popular PNG to Word converters and explains how to use them. You’ll see how each of them works in real scenarios, what their limitations are, and which option is best for different needs.
- Why Converting PNG to Word is Hard
- Using Online PNG to Word Converters
- Using Microsoft Word’s Built-in OCR
- Automate Conversion with Spire.OCR and Spire.Doc
Why Converting PNG to Word Is Not That Simple

A PNG file stores information as pixels rather than structured text. This means Word cannot directly interpret its content unless the image is first processed using OCR (Optical Character Recognition) technology. OCR analyzes visual patterns, identifies characters, and converts them into machine-readable text.
The real challenge in converting PNG to Word is how accurate and usable that Word file is. Layout complexity, tables, mixed fonts, line breaks, and multi-language text can all affect the final result. Different tools handle these elements very differently, which is why the output quality varies significantly even when all of them technically support PNG to Word conversion.
Method 1: Using Online PNG to Word Converters
Online PNG to Word converter tools are usually the fastest way to get editable content from images. They run entirely in the browser and rely on cloud-based OCR engines to recognize text and export Word files. However, different tools vary significantly in accuracy, workflow, and data handling.
Below are three commonly used online tools, each suited to slightly different scenarios.
1. OnlineOCR.net — A Simple Free PNG to Word Converter
OnlineOCR.net is a classic free PNG-to-Word converter option that focuses on simplicity. It has a minimal interface and supports basic OCR for multiple languages, making it suitable for quick text extraction from clear images.

How to convert PNG to Word for free with OnlineOCR.net
- Open the OnlineOCR.net website.
- Upload your PNG file from your local device.
- Select the language of the content on PNG and choose Microsoft Word (DOCX) as the output format.
- Click CONVERT and download the Word file.
Pros
- Free for small files
- No account required
- Straightforward workflow
Cons
- File size and page limits
- Basic formatting only
- Not suitable for batch processing
Best For:
Quick, one-off PNG-to-Word conversions where formatting accuracy is not critical.
2. Smallpdf — A Modern Way to Convert from PNG to Word
Smallpdf offers a more polished user experience and integrates cloud storage platforms such as Google Drive and Dropbox. Unlike simpler tools, it uses a multi-step workflow: image to PDF, then OCR-based export to Word.

How to convert PNG to Word with Smallpdf
- Open the JPG to PDF tool on Smallpdf.
- Drag and drop your PNG file into the upload area. You may also upload from Google Drive, Dropbox, or OneDrive.
- Click Convert to turn the PNG into a PDF.
- Once processing finishes, click Export As and choose Word.
- Enable OCR when prompted to extract editable text.
- Download the generated DOCX file or save it to a cloud service.
Pros
- Clean, beginner-friendly interface
- Cloud storage integration
- Better OCR accuracy than basic tools
Cons
- OCR is limited for free users
- Requires internet upload
- No automation or batch APIs
- Requires multiple steps
Best For:
Users who prioritize a polished online experience and don’t mind a multi-step workflow when converting PNG to Word occasionally, especially when cloud storage integration is needed.
3. Adobe Acrobat Online — A Trusted Brand for Image-to-Word Conversion
Adobe Acrobat Online leverages Adobe’s OCR technology and is often perceived as more reliable for structured documents. It is commonly used when users have already applied Adobe for PDF workflows.

How to Convert PNG File to Word with Adobe Acrobat Online
- Open Adobe Acrobat Online and choose PNG to PDF.
- Upload your PNG image and convert it to a PDF file.
- Download the generated PDF to your device.
- Go back to the Convert section and select PDF to Word.
- Upload the PDF file you just created.
- Convert the file and download the resulting Word document.
Pros
- Strong OCR engine
- Good for business-style documents
Cons
- Requires signing in to download the Word file
- Limited free usage
- Files are processed in the cloud
Best For:
Professional users handling standard documents who value brand reliability.
Method 2: Using Microsoft Word’s Built-in OCR
Many users don’t realize that Microsoft Word includes a basic OCR engine. While Word doesn’t directly open PNG files as editable documents, there is a way that allows you to convert from PNG to Word without extra tools.
Step-by-Step: Convert PNG to Word Using MS Word
- Convert your PNG image to PDF (using Print to PDF or any image-to-PDF tool).
- Open Microsoft Word.
- Use File → Open and select the PDF.
- Word automatically runs OCR and converts the content into an editable document.
- Save the file as a .docx document.
Best For
- Users with Microsoft 365
- Occasional desktop conversions
- No-cost solutions
Limitations
- Manual and time-consuming
- Inconsistent layout for tables and complex formatting
- Not suitable for automation or large volumes
Method 3: Professional Automation with Spire.OCR and Spire.Doc
If you need to process large numbers of images reliably and repeatedly, a professional solution becomes essential. This is when Spire.OCR and Spire.Doc differentiate themselves from the other tools.
Spire.OCR is an OCR API for converting text from PNG images, and Spire.Doc is a Word document API for generating and formatting DOCX files programmatically. Used together, they enable a fully automated PNG-to-Word workflow that scales well for batch processing and system integration.

How the Conversion Workflow Works
- Use Spire.OCR to extract text from PNG images.
- Generate a Word document using Spire.Doc based on text extracted.
- Save the result as a Word file.
Python Code Example: Convert PNG to Word
import os
from spire.ocr import *
# Create an instance of the OCR scanner
scanner = OcrScanner()
configureOptions = ConfigureOptions()
# Set the path to the OCR runtime models
configureOptions.ModelPath = r'E:\DownloadsNew\win-x64'
# Set the target recognition language
configureOptions.Language = 'English'
scanner.ConfigureDependencies(configureOptions)
# Specify the path of the source image
image_path = r'E:/DownloadsNew/pic.png'
# Perform the OCR scan on the image file
scanner.Scan(image_path)
# Get the recognized text content
extracted_text = scanner.Text.ToString()
print("OCR Step Completed. Text Length:", len(extracted_text))
# Import and Use Spire.Doc
if extracted_text.strip():
from spire.doc import Document, FileFormat
# Create a new Word Document instance
doc = Document()
# Add a section to the document
section = doc.AddSection()
# Add a paragraph and append the extracted text
para = section.AddParagraph()
para.AppendText(extracted_text)
# Define the output path for the Word file
output_file = r'E:/DownloadsNew/Output.docx'
# Save the document as a standard .docx file
doc.SaveToFile(output_file, FileFormat.Docx2013)
# Close the document to release resources
doc.Close()
Pros
- Fully automated batch conversion for large volumes of PNG files
- Local processing ensures data privacy and security
- Easily integrates into backend systems or enterprise workflows
Cons
- Requires programming knowledge to use (SDK/API-based)
- Initial setup may take longer than manual tools
- Advanced features require a paid license for full functionality
Best For:
Developers and enterprises that need automated, batch PNG-to-Word conversion as part of systems or document processing workflows.
Conclusion
Online PNG to Word converters are ideal for quick tasks where speed and convenience matter most, while Microsoft Word works well for users who prefer a familiar desktop environment and occasional manual conversions. For developers and businesses dealing with massive images, Spire.OCR and Spire.Doc offer an automated approach for batch processing and system integration. Each method has its own strengths and limitations, and the best choice ultimately depends on your workflow, scale, and long-term needs.
Also Read
Reduce Excel File Size: 6 Proven Ways to Shrink Spreadsheets

We’ve all run into situations like this: trying to send an email to clients, only to have it rejected because the Excel attachment is too large. Or opening a spreadsheet and watching Excel freeze for a full minute before you can even type into a cell. When problems like these start disrupting your workflow, learning how to reduce Excel file size becomes a priority to maintain productivity and ensure smooth data sharing.
In this guide, we’ll walk through several practical techniques to shrink Excel file size, with clear explanations and step-by-step instructions.
- Reduce the Size of an Excel File Manually
- Reduce Excel File Size by Handling Images
- Reduce Excel File Size using Free Spire.XLS for Python
- Reduce File Size in Excel for Large Data Sets
Quick Fixes: How to Reduce the Size of an Excel File Manually
Before diving into complex methods, you can often make an Excel file size smaller by addressing the hidden overhead that accumulates over time.
Clear Excessive Formatting
One of the most common reasons for a bloated file is ghost formatting. You might have formatted an entire column to the bottom of the sheet, which may contain 1,000 rows, even though you only have data in the first 100 rows.
The Fix: Select the empty rows or columns beyond your actual data, then go to the Home tab and click Clear → Clear All to remove all formatting, styles, and other residual data.

If you want to completely remove unused rows or columns, select the entire rows or columns by clicking their headers, right-click, and choose Delete.
Save as Binary Format (.xlsb)
If you want to decrease Excel file size instantly without losing any data, try changing the file extension. Saving your standard .xlsx file as a binary workbook (.xlsb) can often reduce the file size of an Excel file by 30% to 50%. Binary files are faster for Excel to read and write, making them perfect for massive datasets.
The Fix: Open the Excel file, click the File tab, choose Save As, and select the .xlsb format. Alternatively, you can rename the file directly and change the extension to .xlsb, but this approach may cause file corruption and is not recommended.

Visual Optimization: How to Reduce Excel File Size by Handling Images
Images are often the biggest reason behind a massive file. If your spreadsheet contains logos, screenshots, or product photos, you must optimize them to compress the Excel file size effectively.
The Fix: Click on any image in your workbook, go to the Picture Format tab, and select Compress Pictures.

Pro Tip: Uncheck "Apply only to this picture" to compress all images at once and select "Email (96 ppi)" for the maximum reduction in weight. This is the fastest way to reduce file size in Excel when visual fidelity isn't the top priority.
Professional Approach: Reduce Excel File Size using Free Spire.XLS for Python
For developers or businesses dealing with hundreds of files, manual clicking isn't efficient enough. A more robust way to minimize Excel file size is through automation. Free Spire.XLS for Python is a powerful library that allows you to programmatically optimize spreadsheets without even opening Microsoft Excel.
Why use a programmatic approach?
While manual fixes work for one-off tasks, Free Spire.XLS allows you to implement deep optimization logic in bulk:
-
Compressing Image Quality: You can iterate through every worksheet, identify media elements, and utilize the ExcelPicture.Compress() method to programmatically decrease image quality. This significantly reduces the storage footprint while maintaining acceptable visual clarity for reports.
-
Cleaning Redundant Cell Styles: By applying the Clear(ExcelClearOptions.ClearFormat) method to specific ranges, Free Spire.XLS allows you to strip away these redundant styles and metadata, effectively thinning the file’s internal structure without affecting the underlying data.
-
Optimization of Data Storage: Blank rows or columns that appear empty but contain invisible formatting can trick Excel into expanding the used range. You can use the Worksheet.DeleteRow() and Worksheet.DeleteColumn() methods to remove these empty rows and columns. This ensures your Excel file size reduction efforts are thorough, leaving you with a clean, high-performance dataset.
The following code snippet demonstrates how to integrate these three methods to shrink Excel file size using Free Spire.XLS for Python:
from spire.xls import *
from spire.xls.common import *
# 1. Initialize and load the workbook
workbook = Workbook()
input_path = "/input/sample excel.xlsx"
output_path = "/output/Compressed_Excel_Full.xlsx"
workbook.LoadFromFile(input_path)
# 2. Iterate through worksheets to perform optimization operations
for i in range(workbook.Worksheets.Count):
sheet = workbook.Worksheets[i]
# Compress Image Quality
for picture in sheet.Pictures:
picture.Compress(50) # Compress to 50% quality
# Clear Specific Range Formatting
target_range = sheet.Range["A1:D1"]
target_range.Clear(ExcelClearOptions.ClearFormat)
# Iterate through rows in reverse (from last to first) to avoid index shifting
for r in range(sheet.LastRow, 0, -1):
if sheet.Rows[r-1].IsBlank:
sheet.DeleteRow(r)
# Iterate through columns in reverse
for c in range(sheet.LastColumn, 0, -1):
if sheet.Columns[c-1].IsBlank:
sheet.DeleteColumn(c)
# Save the file and release resources
workbook.SaveToFile(output_path, ExcelVersion.Version2016)
workbook.Dispose()
print(f"Successfully optimized! File saved to: {output_path}")
Excel File size before and after reducing with the code:

Advanced Tactics: How to Reduce File Size in Excel for Large Data Sets
When your spreadsheet is heavy due to data rather than media, you need to change how that data is stored.
Use the Data Model (Power Pivot)
If you are dealing with millions of rows, stop keeping them in standard worksheets. Importing data into the Excel Data Model (Power Pivot) uses a highly efficient compression engine (Vertipaq) that can handle massive amounts of information while keeping the file footprint remarkably small.
Remove Hidden Sheets and Objects
Sometimes, old versions of a file contain hidden sheets or objects that you’ve forgotten about. Go to the Inspect Document tool (File > Info > Check for Issues) to find and remove hidden content that might be inflating your file size.
Conclusion
Reducing Excel file size is essential for improving performance and ensuring seamless data sharing. For quick, one-off fixes, manual methods like saving as Binary Format (.xlsb) or using built-in image compression are highly effective to shrink Excel file size.
However, for developers managing high-volume data, automation is the ultimate solution. As demonstrated, Free Spire.XLS for Python provides a powerful way to minimize Excel file size by programmatically purging redundant formatting, compressing media, and cleaning up "ghost cells." By combining these manual and programmatic strategies, you can ensure your workbooks remain fast, lightweight, and professional.
Also Read
How to Embed a PDF in Excel With or Without Microsoft Office
Table of Contents

Have you ever sent an Excel report, only to realize the recipient couldn't see the supporting evidence because you forgot to attach the original PDF contracts or invoices? It is a common challenge.
Embedding a PDF in an Excel file is the ultimate solution to keep your data and its "proof" together. Whether you are looking for a quick manual fix or needing to automate thousands of reports on a server, this guide covers how to get it done—with or without Microsoft Office installed.
- What Does Embedding Mean
- Embed a PDF in Excel File with Microsoft Office
- Embed a PDF Document in Excel with Code
- Display PDF Content as Images
- Supplement: Linking vs. Attaching
- Compare Microsoft Office and Free Spire.XLS
- FAQs
What Does "Embedding" Really Mean?
Before we dive into the how to embed a PDF in Excel spreadsheets, it is important to understand that embedding can look different depending on your goals. There are three common ways to embed a PDF file in an Excel worksheet:
-
OLE Object Embedding: The PDF is bundled inside the Excel file. If you send the Excel file, the PDF goes with it.
-
Visual Embedding: The PDF pages are converted into images and placed on the sheet. The content shows immediately, but there is no PDF file to open or check.
-
Hyperlinking: You create a clickable link to a PDF stored on your PC or the cloud. As a result, when you share the Excel file, the recipient will often be unable to access or view the PDF due to missing files, broken paths, or permission issues. This isn't a true embed, but it keeps the Excel file size small.
Method 1: Embed a PDF in Excel File with Microsoft Office
As the world’s most popular spreadsheet software, Microsoft Office provides a built-in "Object" tool that allows you to easily embed a PDF in an Excel file. This is the most straightforward and common method, especially if your device already has the Microsoft Office suite installed and you only have a few files to process manually.
How to embed a PDF document in Excel via "Insert Object"
- Open your Excel file and go to the Insert tab.
- On the far right, click on Object.
- In the dialog box, go to the Create from File tab and browse for your PDF.
- Check "Display as icon" if you want a neat PDF logo in your cell.
- Leave it unchecked if you want to see a small preview of the first page.

- Click OK.
The Pros: It’s free and very easy.
The Cons: The Cons: It is not suitable for batch processing, and it relies heavily on the local system’s OLE configuration.
Method 2: Embed a PDF Document in Excel with Code
What if you are building a web application or a server-side service that needs to generate reports with PDF attachments? It is not recommended to install Microsoft Office on a server just for this. This is where Free Spire.XLS comes in. It embeds a PDF in an Excel worksheet by inserting OLE objects.

How to embed a PDF in an Excel file programmatically
Using a library like Free Spire.XLS allows you to automate the process without opening the Excel interface. You can precisely place a PDF into a specific cell range using code.
For developers, the key is the OleObjectType enumeration. Since you are dealing with PDFs, you would use OleObjectType.AdobeAcrobatDocument.
Here's how it works in Python:
- Install Free Spire.XLS and import the essential modules.
- Create Workbook object and load an Excel file.
- Access the target worksheet.
- Load an image to use as the placeholder icon.
- Embed a PDF in the Excel file using the Worksheet.OleObjects.Add() method.
- Specify the display location of the OLE object, and set the OLE object type to AdobeAcrobatDocument through OleObjectType property.
- Save the modified Excel workbook.
Below is a sample code:
from spire.xls import *
from spire.xls.common import *
# Create a Workbook object and load an Excel file
workbook = Workbook()
workbook.LoadFromFile("/input/sales report.xlsx")
# Get the first worksheet
sheet = workbook.Worksheets[0]
# Add a descriptive label to cell A16
sheet.Range["A16"].Text = "Here is an OLE Object."
# Define the paths for the PDF and the placeholder icon
pdf_path = "/input/sample.pdf"
icon_path = "/pdf.png"
# Read the icon image as a byte stream
with open(icon_path, 'rb') as f:
img_data = f.read()
icon_stream = Stream(img_data)
# Add the PDF as an embedded OLE object using the image stream
oleObject = sheet.OleObjects.Add(pdf_path, icon_stream, OleLinkType.Embed)
# Specify the display location of the OLE object
oleObject.Location = sheet.Range["A17"]
# Set the OLE object type to AdobeAcrobatDocument (Standard for PDFs)
oleObject.ObjectType = OleObjectType.AdobeAcrobatDocument
# Save the modified workbook to the output directory
workbook.SaveToFile("/output/OleObject.xlsx", ExcelVersion.Version2016)
# Dispose of the workbook to release resources
workbook.Dispose()
Output file preview:

Why go the "Without Office" route with Free Spire.XLS?
- Massive Automation: You can loop through a folder of 500 PDFs and embed each one into a corresponding row in seconds.
- Precision: You can set the exact height, width, and cell coordinates for the PDF icon.
- No Dependencies: Your server doesn't need Excel installed, which is safer and more efficient for enterprise environments.
Method 3: Display PDF Content as Images
Sometimes, you don't want your users to have to double-click an icon; you want them to see the content of the PDF as they scroll through the spreadsheet. Then you can insert screenshot images of a PDF by pasting it into an Excel file.
How to embed a PDF file in an Excel worksheet as an image
-
With Office: You can use the "Screen Clipping" tool or take a screenshot of the PDF and paste it into Excel.
-
Without Office: You can use a two-step automated process. First, use a PDF library to convert the PDF pages into images (PNG or JPEG), then use Free Spire.XLS to insert those images into the worksheet.
This is the best solution for embedding a PDF file when the visual data is more important than the actual file format.
Supplement: Linking vs. Attaching
If you are worried about your Excel file becoming too large and slowing down the opening and processing speed, you should consider linking instead of embedding PDFs.
-
Embedding (Attachment): The PDF is part of the
.xlsxfile. High portability, high file size. -
Linking (Hyperlink): The Excel file only stores the "path" to the PDF. Low file size, but if you move the PDF or send the Excel file to someone else, the link will break.
A Side-by-Side Comparison: Microsoft Office vs. Free Spire.XLS
To help you quickly identify the most suitable solution, this section compares Microsoft Office and Free Spire.XLS across four key dimensions that matter most when embedding PDFs into Excel files:
| Requirement | Microsoft Office | Free Spire.XLS |
|---|---|---|
| Installation | Requires Microsoft Office | Requires Free Spire.XLS DLL |
| Processing Speed | Manual and time-consuming | Automated and fast |
| Flexibility | Drag-and-drop, limited control | Logic-driven and highly extensible |
| Best Use Case | Individual desktop use | Server-side or production environments |
FAQs about Embedding a PDF in an Excel File
1. How do I embed a PDF in Excel?
You can use the "Insert Object" menu in Office or the Worksheet.OleObjects.Add() method in Free Spire.XLS for automation.
2. How do I embed a file in Excel as an attachment?
Follow the "Insert Object" steps and always check "Display as Icon." This treats the file like a clickable attachment.
3. Can you embed a PDF in Google Sheets?
No. Google Sheets does not support OLE embedding. Your only option there is to upload the PDF to Google Drive and use a hyperlink.
Conclusion
Deciding how to embed a PDF in Excel depends largely on your working environment. For business users handling a one-off report, the built-in "Insert" and "Object" feature in Microsoft Office is usually sufficient. However, if you are an IT professional or developer who needs to scale or automate the process, an Office-independent solution such as Free Spire.XLS is a better fit. Choosing the right approach ensures your Excel files remain organized, professional, and—most importantly—complete.
Also Read
Embed Video in PDF: 4 Practical Ways to Add Videos to a PDF
Table of Contents

Can you embed a video in a PDF? The answer is yes, you can. Even though PDF documents are not designed for multimedia, there are several ways to add videos to a PDF. In this guide, we'll walk you through 4 practical approaches to embed video in PDF documents, explain how they work and the tools involved. Let's find the best method for you today!
- Understanding How Video Works in a PDF Document
- Approach 1 – Embed Video as Rich Media
- Approach 2 – Attach Video Files to a PDF
- Approach 3 – Add Video via Hyperlinks
- Approach 4 – Online Editors
- Comparison Table of 4 Methods
- FAQs
Understanding How Video Works in a PDF Document
Before looking at specific approaches, it helps to understand a key limitation: PDF is not a video-oriented format. When you embed a video in a PDF file, it's either storing the video inside the file, adding it as an attachment, or linking to a video stored locally or hosted on platforms like YouTube.
These differences matter because they directly affect whether a video can play offline, how large the PDF file becomes, and how consistently the document works across different PDF readers. With these considerations in mind, let’s take a closer look at the main approaches to embedding video in a PDF.
Approach 1 – Embed Video as Rich Media (True Embedded Video)
This is the closest approach to video embedding in a PDF. The Rich Media feature uses special PDF annotations that allow a video to be stored inside the document and played directly on the page.
From a technical perspective, it relies on PDF Rich Media Annotations, where the video file is embedded as part of the PDF structure. When it works as expected, the video will appear inline and can even be played offline.
However, this approach comes with an important caveat. Rich media support depends heavily on the PDF reader being used. In practice, you may encounter a situation where a video embedded with Adobe Acrobat plays perfectly in Adobe Acrobat or Adobe Reader but fails to play or does not appear at all when the same PDF is opened in other PDF viewers. For this reason, rich media is best suited for scenarios where the viewing environment is known in advance and Adobe-compatible readers are guaranteed.
Typical steps (Adobe Acrobat Pro):
- Open the PDF file in Adobe Acrobat Pro.
- Go to the Tools panel and locate Rich Media.
- Click Add Video, then drag to define the area on the page where the video should appear.
- Choose a local video file or enter a video URL, and click OK to confirm.

Tools that support this approach:
- Adobe Acrobat Pro
Pros and cons:
- Video is stored inside the PDF and can play offline.
- Limited compatibility and reliance on specific PDF readers.
Approach 2 – Attach Video Files to a PDF
Another way to embed a video in a PDF document is by adding it as an attachment. In this approach, the video file is stored inside the PDF package but is not displayed directly on the page.
The video appears as an attached file that users can open manually. While this feels less interactive, it offers much broader compatibility across different PDF readers and avoids many of the limitations associated with rich media playback.
Using Adobe Acrobat
Adobe Acrobat allows you to attach video files to a PDF as embedded files. The attached video can be accessed through the attachments panel or a file icon placed on the page.
Typical steps:
- Open the PDF file in Adobe Acrobat. Go to the Tools panel or the right-hand sidebar and select Comment.
- In the top toolbar, click Attach File (Add a new attachment).
- Click on the page to choose where the attachment icon should appear, then select the video file.
- Customize the attachment settings if needed, and click OK to finish adding the video file.

This method is commonly used when all related materials must be delivered together in a single, self-contained document.
Using Free Spire.PDF
With Free Spire.PDF, you can embed videos on a PDF as attachments in a programming way. This PDF library helps developers to add attachments to PDF documents automatically. The following example uses Python, but the overall workflow is similar in Java and C#.
Typical steps:
- Install Free Spire.PDF in your Python environment. And import the required modules.
- Load the existing PDF document and prepare the video file to be attached.
- Add the video file to the PDF as an embedded attachment.
- Save the updated PDF document.

Here's the complete code you can follow:
from spire.pdf import *
from spire.pdf.common import *
# Create a PdfDocument object
doc = PdfDocument()
# Load a sample PDF file
doc.LoadFromFile("\\Input.pdf")
# Create PdfAttachment objects based on external files
attachment = PdfAttachment("\\sample.mp4")
# Add the attachments to PDF
doc.Attachments.Add(attachment)
# Save to file
doc.SaveToFile("\\Attachment.pdf")
This approach works well in automated or programmatic workflows, especially when generating PDFs in bulk or integrating video files as supporting materials.
Use cases:
- Legal documents that require all supporting files to be bundled together.
- Technical deliveries or project handovers.
- Scenarios where file completeness is more important than inline playback.
Overall, attaching video files to a PDF strikes a balance between reliability and simplicity. It may not provide the smoothest viewing experience, but it remains a dependable option for professional environments.
Approach 3 – Add Video via Hyperlinks (Most Compatible)
Embedding a video in a PDF using hyperlinks is the most common and direct way. Technically speaking, the video is not embedded in the PDF. Instead, the document contains a clickable link that points to the video file.
In practice, this is what most people mean when they ask how to embed a video in a PDF. It works in almost every PDF reader while keeping the PDF file sizes small and avoiding many security issues.
The video content can be hosted on:
- YouTube or other online video platforms.
- A local video file on the user’s device.
- Cloud storage services.
Using Adobe Acrobat
Adobe Acrobat allows you to add hyperlinks to text, images, or specific areas of a page. When a reader clicks the link, the video opens in the default browser or media player.
Typical steps:
- Open the PDF document in Adobe Acrobat.
- Right-click on the text, image, or area where you want to place the video link, and select Create Link.
- Set the Link Action to Open a file (for a local video file) or Open a web page (for an online video).
- Click Next, then choose the video file or enter the video URL.

This method is simple and reliable, making it a common choice for instructional documents and online-ready PDFs.
Using Free Spire.PDF
Free Spire.PDF allows you to add hyperlinks to PDF as well. While the implementation is done through code, you don't have to worry about manual errors.
Typical steps:
- Load the existing PDF document.
- Locate the target text using a text search method and define it as the link area.
- Set the hyperlink target to a video URL or a local video file.
- Save the updated PDF document.
Here's the code example you can follow:
from spire.pdf.common import *
from spire.pdf import *
# Create a PdfDocument instance
pdf = PdfDocument()
# Load a PDF file
pdf.LoadFromFile("input.pdf")
# Get the first page
page = pdf.Pages.get_Item(0)
# Find all occurrences of the specified text on the page
collection = page.FindText("Christmas Songs", TextFindParameter.IgnoreCase)
# Loop through all occurrences of the specified text
for find in collection.Finds:
# Create a hyperlink annotation
uri = PdfUriAnnotation(find.Bounds)
# Set the URL of the hyperlink
uri.Uri = "https://youtu.be/ombP9z_ir8c?si=Wq2U-HWeSyJQda-0"
# Set the border of the hyperlink annotation
uri.Border = PdfAnnotationBorder(1.0)
# Set the color of the border
uri.Color = PdfRGBColor(Color.get_Blue())
# Add the hyperlink annotation to the page
page.AnnotationsWidget.Add(uri)
#Save the result file
pdf.SaveToFile("SearchTextAndAddHyperlink.pdf")
pdf.Close()
This method is especially useful in automated workflows where PDFs are generated or modified in batches.
Why this is the most common method:
- Simple and easy to implement.
- Best compatibility across devices and PDF readers.
- Minimal impact on PDF file size.
- Lower security and stability risks.
For most business, educational, and documentation scenarios, adding videos via hyperlinks is the safest and most practical solution.
Approach 4 – Online Editors: Convenience over Control
We discuss online PDF editors in a separate section, not because they introduce a new embedding method, but because they provide a distinct usage scenario. They allow you to upload a PDF, insert video link online without installing third-party applications.
Typical steps (online PDF editors, e.g. Smallpdf):
- Upload the PDF file to the online editor.
- Insert a thumbnail image to represent the video.
- Add a clickable link to the video URL (on the image or as nearby text).
- Download and test the updated PDF.
Advantages and risks:
- No installation required.
- Potential privacy and compliance concerns.
- Limited file size and feature control.
Online tools are suitable for lightweight, non-sensitive tasks but are usually not ideal for enterprise or long-term workflows.
Comparison: Which Approach Should You Choose?
| Approach | Offline Playback | File Size | Compatibility | Best Tools |
|---|---|---|---|---|
| Rich Media | Yes | Large | Low | Adobe Acrobat Pro |
| Attachment | Yes | Large | Medium | Adobe Acrobat, Spire.PDF |
| Hyperlink | No | Small | High | Adobe Acrobat, Spire.PDF |
| Online Editors | No | Small | High | Web-based PDF tools |
Each method serves a different purpose. If offline playback is required, rich media may be an option. If reliability and readability matter most, hyperlinks are usually the better choice.
Conclusion
Embedding videos in PDFs is less about finding a single perfect method and more about understanding the trade-offs of each approach. Once you align the technique with your audience and distribution scenario, choosing the right solution becomes much easier.
FAQ: Embedding Videos in PDF Documents
Q1: Can you embed a video in a PDF document and play it offline?
Yes, but only when the video is added as rich media or as an attached file. Hyperlinks can point to local video files, but offline playback usually fails on other devices because the linked file is not available.
Q2: Why doesn’t my embedded video play in some PDF readers?
Many PDF readers restrict or completely block rich media features for security reasons. As a result, embedded videos may only work reliably in Adobe Acrobat and a few compatible viewers.
Q3: Can PDFs support videos or animated content like GIFs?
Yes. PDFs can support videos through rich media, file attachments, or hyperlinks, and GIFs can be inserted as images. However, support varies depending on the PDF reader and platform.