This article demonstrates how to replace text in Excel using the WorksheetsApi interface provided by Spire.Cloud.Excel.
using Spire.Cloud.Excel.Sdk.Api;
using Spire.Cloud.Excel.Sdk.Client;
using System;
namespace ReplaceText
{
class Program
{
static String appId = "App ID";
static String appKey = "App Key";
static String baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration instance based on App ID and App Key
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create a WorksheetsApi instance
static WorksheetsApi WorksheetsApi = new WorksheetsApi(configuration);
static void Main(string[] args)
{
//Specify the input file name
string name = "Input.xlsx";
//Specify the folder where the input file is stored
string folder = "input";
//Specify the worksheet name
string sheetName = "Sheet1";
//Specify the text to be replaced
string oldValue = "North America";
//Specify the desired text used to replace the above text
string newValue = "replace";
//Specify whether it is case sensitive
bool matchCase = true;
//Use the 2G storage provided by E-iceblue, and it's "null" by default
string storage = null;
//Call ReplaceText method to replace text in the worksheet and save the result file
WorksheetsApi.ReplaceText(name, sheetName, oldValue, newValue, matchCase, folder, storage);
}
}
}
The input Excel file:
The output Excel file: