How to Generate QR Codes in Excel

CreationTools & Apps

Published

Share
Illustration for How to Generate QR Codes in Excel

Overview

A practical way to generate QR codes from Excel data is to build a QR image URL, then display it with IMAGE(). The QR service creates the code; Excel displays the returned image. This combines Microsoft’s documented image function with a QR API—not a native QR-encoding function. [1]

Below is a formula example for supported Windows editions, followed by options for Mac, web, and saved images. The example uses QuickChart’s documented API to make the workflow concrete; it is not a service comparison or a claim of hands-on testing.

Before you start: check compatibility and data privacy

Microsoft documents IMAGE for Microsoft 365 and Excel 2024, including Mac editions. However, ENCODEURL, used in the Windows example below, is unavailable on Mac and Excel for the web. [2] Do not assume the entire formula works everywhere that images can appear. [1]

Also decide whether your data may leave your organization. In this example, the cell’s contents become the QR API’s text parameter, so the QR provider receives that content. Use only non-sensitive sample data unless your organization has approved the service. Office Scripts that make external requests also send data outside the workbook. [3][4]

Method 1: Generate a QR image URL with a Windows formula

Use this method in Excel for Microsoft 365 or Excel 2024 on Windows, subject to external-image access being permitted. It combines ENCODEURL with IMAGE. [1][2]

1. Set up three columns

Use this layout for your first record:

Cell What to enter
A1 Content
B1 QR image URL
C1 QR code
A2 A non-sensitive URL or text value to encode

2. Build the image URL in B2

Enter:

="https://quickchart.io/qr?format=png&size=300&margin=4&text="&ENCODEURL(A2)

QuickChart documents text as the content to encode, size as image width and height in pixels, and margin as whitespace measured in modules—the small squares that make up the QR code. This example requests a 300-pixel PNG with a four-module margin. [4]

ENCODEURL(A2) encodes the payload for inclusion in the request URL. Keep it around the cell value rather than the entire API address. QuickChart specifically instructs users to URL-encode the text parameter. [4][2]

3. Display the QR code in C2

Enter:

=IMAGE(B2,"QR code for row 2",0)

The final 0 fits the image inside the cell while preserving its proportions. Enlarge the row and column as needed; avoid sizing mode 1, which can distort the image. Microsoft also recommends referencing a cell when the image URL is long. [1]

4. Validate one row before filling down

Before extending the formulas:

  1. Scan C2 and compare the decoded content with A2.
  2. Include a sample containing spaces, punctuation, or URL query parameters.
  3. Check that each QR image stays paired with its intended record.
  4. Only then fill B2 and C2 down through the required rows.

Treat this as a validation checklist, not a report of tests performed for this article. For larger jobs, review the selected provider’s current usage limits and your organization’s data policy before processing the full sheet.

Method 2: Use prepared URLs or saved QR images

On Mac or Excel for the web

Do not copy the Windows formula unchanged: its ENCODEURL component is unsupported on these platforms. Instead, prepare correctly encoded, direct HTTPS image URLs outside that formula, then use IMAGE where supported—or insert saved QR images. [2]

Insert a saved image

For a small, fixed set of codes, consider generating approved PNG files first and inserting them into the workbook.

Microsoft documents this path for supported Microsoft 365 and Excel 2024 editions:

  1. Select the destination cell.
  2. Choose Insert → Illustrations → Pictures → Place in Cell.
  3. Choose This Device, select the QR image, and insert it.

If that feature is unavailable in your build, check its supported picture-insertion options rather than assuming the menu will match. Microsoft also warns that inserting multiple pictures in cells overwrites existing values in the destination cells. [5]

Method 3: Use Office Scripts for a repeatable workflow

Office Scripts is an automation option, not a ready-made QR generator. Microsoft’s image sample fetches an image, converts it to Base64, and adds it to a worksheet. A developer can adapt that insertion workflow to QR images from an approved source; the sample itself does not encode QR data. [6]

Before choosing this route, check your Microsoft 365 license, supported Excel client, and administrator settings. Office Scripts is not available merely because a workbook supports formulas. [7]

Power Automate requires a different external-fetch design. Microsoft explicitly states that its URL-image sample does not work there because it uses fetch. Retrieve external data with an appropriate flow action and pass the necessary data into the script instead of moving the sample unchanged into a flow. [6]

Troubleshooting and scan checks

Symptom What to check
Image does not appear Use a direct HTTPS image URL. Authentication-required URLs do not render, and redirected sources are blocked.
#BLOCKED! Check external-content restrictions with your administrator; do not bypass organizational policy.
#CONNECT! Check the network connection and image server.
Windows formula fails on Mac or web Replace the unsupported ENCODEURL step with a prepared image URL or saved image.

Microsoft documents the image loading errors and the platform limits for ENCODEURL separately. [1][2]

If Excel blocks the external image, use a saved QR image from an approved source. For scan reliability, preserve the square shape and the clear border. DENSO WAVE specifies a quiet zone four modules wide on every side of a standard QR Code; do not crop that space away. [8]

Before distributing labels or a PDF, scan the final exported or printed output at its intended size and compare it with the source record. The example’s 300-pixel setting is not a guaranteed physical print size.

Which method should you choose?

Our editorial recommendation: start with one non-sensitive row and the Windows formula if your environment supports it. Use saved images for a small, fixed deliverable. Consider Office Scripts only when repeatable insertion and workbook management justify the development work—and validate the actual deployment environment before scaling.

References

[1] Microsoft Support, IMAGE function — https://support.microsoft.com/en-us/excel/functions/image-function

[2] Microsoft Support, ENCODEURL function — https://support.microsoft.com/en-us/excel/functions/encodeurl-function

[3] Microsoft Learn, External API call support in Office Scripts — https://learn.microsoft.com/en-us/office/dev/scripts/develop/external-calls

[4] QuickChart, QR Code API — https://quickchart.io/documentation/qr-codes/

[5] Microsoft Support, Insert a picture with the Place in Cell feature in Excel — https://support.microsoft.com/en-us/excel/insert-picture-in-cell-in-excel

[6] Microsoft Learn, Add images to a workbook — https://learn.microsoft.com/en-us/office/dev/scripts/resources/samples/add-image-to-workbook

[7] Microsoft Learn, Platform limits and requirements with Office Scripts — https://learn.microsoft.com/en-us/office/dev/scripts/testing/platform-limits?tabs=business

[8] DENSO WAVE, Point for determining the code area — https://www.qrcode.com/en/howto/code.html

Ready to create your QR code?

Create QR Code