Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 905 Bytes

Loading-and-Modifying-Files.md

File metadata and controls

34 lines (27 loc) · 905 Bytes

Loading a workbook created with ClosedXML:

var workbook = new XLWorkbook("BasicTable.xlsx");

BasicTable.jpg

Modifying the workbook:

var ws = workbook.Worksheet(1);

// Change the background color of the headers
var rngHeaders = ws.Range("B3:F3");
rngHeaders.Style.Fill.BackgroundColor = XLColor.LightSalmon;

// Change the date formats
var rngDates = ws.Range("E4:E6");
rngDates.Style.DateFormat.Format = "MM/dd/yyyy";

// Change the income values to text
var rngNumbers = ws.Range("F4:F6");
foreach (var cell in rngNumbers.Cells())
{
  cell.DataType = XLCellValues.Text;
  cell.Value += " Dollars";
}

BasicTableModified.jpg

Saving the workbook:

workbook.SaveAs("BasicTable_Modified.xlsx");