PNG
JPG
BMP
TIFF
XLSB
Redact XLSB Formats in C#
Native and high performance XLSB document sensitive redaction information using server-side Aspose.Cells for .NET APIs, without the use of any software like Microsoft or Adobe PDF.
How to Redact XLSB File Using C#
In order to redact XLSB file, we’ll use Aspose.Cells for .NET API which is a feature-rich, powerful and easy to use document manipulation API for C# platform. Open NuGet package manager, search for Aspose.Cells and install. You may also use the following command from the Package Manager Console.
Command
PM> Install-Package Aspose.Cells
Steps to Redact XLSB Files in C#
A basic document search and replace text in contents, comments or metadata with Aspose.Cells for .NET APIs can be done with just few lines of code.
- Load XLSB file.
- Select the sheet.
- Create FindOptions object.
- Set Search Options
- Loop through each cell and use Find method.
- Save the workbook.
System Requirements
Our APIs are supported on all major platforms and Operating Systems. Before executing the code below, please make sure that you have the following prerequisites on your system.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Mono or Xamarin Platforms
- Development environment like Microsoft Visual Studio
- Add reference to the Aspose.Cells for .NET DLL in your project - Install from NuGet using the Download button above
Redact XLSB Files - C#
Workbook wb = new Workbook("e:\test2\Input.xlsb");
Worksheet sheet = wb.Worksheets[0];
FindOptions opts = new FindOptions();
opts.LookInType = LookInType.Values;
opts.LookAtType = LookAtType.Contains;
opts.RegexKey = true;
Aspose.Cells.Cell cell = null;
do
{ //find only whole word and not part of any word.
cell = sheet.Cells.Find("\bKIM\b", cell, opts);
if (cell != null)
{
string celltext = cell.Value.ToString();
celltext = celltext.Replace("KIM", "^^^^^^^^^^");
cell.PutValue(celltext);
}
}
while (cell != null);
wb.Save("e:\test2\out1.xlsb");
// Find/Replace in whole workbook.
Workbook wb = new Workbook("e:\test2\Input.xlsb");
wb.Replace("\bKIM\b", "^^^^^^^^", new ReplaceOptions() { RegexKey = true });
wb.Save("e:\test2\output.xlsb");