Click or drag to resize

XlsWorksheet Replace Method (String, DateTime)

Replaces cells' values with new data.
Examples
The following code illustrates how to replace the string value with datetime:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Replace the oldValue by dateTime</para><para>string oldValue = "Find";</para><para>DateTime dateTime = DateTime.Now;</para><para>worksheet.Replace(oldValue, dateTime);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>

Namespace: Spire.Xls.Core.Spreadsheet
Assembly: Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
public void Replace(
	string oldValue,
	DateTime newValue
)

Parameters

oldValue
Type: System String
String value to replace.
newValue
Type: System DateTime
New value for the range with specified string.

Implements

IWorksheet Replace(String, DateTime)
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
See Also