- using System.Drawing;
- using Spire.Xls;
-
- namespace Excel查找和替换
- {
- class Program
- {
- static void Main(string[] args)
- {
- Workbook workbook = new Workbook();
- workbook.LoadFromFile("统计表.xlsx");
-
- Worksheet sheet = workbook.Worksheets[0];
- CellRange[] ranges = sheet.FindAllString("Canada", false, false);
- foreach (CellRange range in ranges)
- {
- range.Text = "British";
- range.Style.Color = Color.LawnGreen;
- }
-
- workbook.SaveToFile("替换.xlsx");
- System.Diagnostics.Process.Start("替换.xlsx");
- }
- }
- }
之前
之后