Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -6748,30 +6748,33 @@
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-remove-all-the-listobjects-from-the-sheet">How to remove all the ListObjects from the sheet?</a>
</li>
<li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-assign-cell-value-without-changing-format-type-in-xlsio">How to assign cell value without changing the format type in XlsIO?</a>
</li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-retrieve-data-from-merged-cells-using-xlsio">How to retrieve data from merged cells using XlsIO?</a>
</li>
<li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-convert-inches-to-points-in-syncfusion-xlsio">How to convert inches to points in Syncfusion XlsIO?</a>
</li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-preserve-line-breaks-when-saving-excel-as-csv">How to preserve line breaks when saving Excel as CSV?</a>
</li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-preserve-line-breaks-when-saving-excel-as-csv">How to preserve line breaks when saving Excel as CSV?</a>
</li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/why-text-with-double-quotes-gets-enclosed-in-double-quotes-when-saving-as-csv">Why does text with double quotes get enclosed in double quotes when saving as CSV?</a>
</li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-detect-whether-a-column-is-hidden-in-an-excel-file-using-xlsio">How to detect whether a column is hidden in an Excel file using XlsIO?</a>
</li>
<li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-set-invert-if-negative-option-for-a-chart">How to set invert if negative option for a chart using XLsIO?</a>
</li>
<li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-merge-cells-preserving-topleft-value-and-format-in-xlsio">How to merge cells preserving topleft value and format in XlsIO?</a>
</li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-open-excel-file-as-readonly-option-in-microsoft-excel-using-xlsio">How to open Excel file as ReadOnly in Microsoft Excel using XlsIO?</a>
</li>
</ul>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: How to Open Excel as Read‑Only using XlsIO | Syncfusion
description: Shows how to set the 'Read-only recommended' flag when saving an Excel workbook with Syncfusion XlsIO so Excel prompts to open it as read-only.
platform: document-processing
control: XlsIO
documentation: UG
---

# How to open Excel file as ReadOnly in Microsoft Excel using XlsIO?

You can make Excel prompt users to open a workbook as read-only by setting the Read-only recommended flag on the workbook before saving. The example below shows how to set this flag with Syncfusion XlsIO and save the file so Microsoft Excel offers the "Read-only recommended" option when the file is opened.

The following code examples illustrate this.

{% tabs %}
{% highlight c# tabtitle="C# [Cross-platform]" %}
using (ExcelEngine excelEngine = new ExcelEngine())
{
// Instantiate the Excel application object
IApplication application = excelEngine.Excel;

// Assigns default application version
application.DefaultVersion = ExcelVersion.Xlsx;

// Create a workbook with 1 worksheet
IWorkbook workbook = application.Workbooks.Create(1);

// Access first worksheet from the workbook
IWorksheet worksheet = workbook.Worksheets[0];

// Adding text to a cell
worksheet.Range["A1"].Text = "Hello World";

// Protect the worksheet
worksheet.Protect("syncfusion", ExcelSheetProtection.All);

// Save the workbook to disk in XLSX format
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
}
{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}
using (ExcelEngine excelEngine = new ExcelEngine())
{
// Instantiate the Excel application object
IApplication application = excelEngine.Excel;

// Assigns default application version
application.DefaultVersion = ExcelVersion.Xlsx;

// Create a workbook with 1 worksheet
IWorkbook workbook = application.Workbooks.Create(1);

// Access first worksheet from the workbook
IWorksheet worksheet = workbook.Worksheets[0];

// Adding text to a cell
worksheet.Range["A1"].Text = "Hello World";

// Protect the worksheet
worksheet.Protect("syncfusion", ExcelSheetProtection.All);

// Save the workbook to disk in XLSX format
workbook.SaveAs("Output.xlsx");
}
{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
Using excelEngine As New ExcelEngine()
' Instantiate the Excel application object
Dim application As IApplication = excelEngine.Excel

' Assigns default application version
application.DefaultVersion = ExcelVersion.Xlsx

' Create a workbook with 1 worksheet
Dim workbook As IWorkbook = application.Workbooks.Create(1)
' Access first worksheet from the workbook
Dim worksheet As IWorksheet = workbook.Worksheets(0)

' Adding text to a cell
worksheet("A1").Text = "Hello World"

' Protect the worksheet
worksheet.Protect("syncfusion", ExcelSheetProtection.All)

' Save the workbook to disk in XLSX format
workbook.SaveAs("Sample.xlsx")
End Using
{% endhighlight %}
{% endtabs %}


A complete working example in C# is present on <a href="https://github.com/SyncfusionExamples/XlsIO-Examples/tree/992377-ReadOnly-Excel/FAQ/ReadOnly%20Excel/.NET/Readonly%20Excel">this GitHub page</a>.