C1XLBook book = new C1XLBook();
// step 2: get the sheet that was created by default, give it a name
XLSheet sheet = book.Sheets[0];
sheet.Name = "Hello World";
// step 3: create styles for odd and even values
XLStyle styleOdd = new XLStyle(book);
styleOdd.Font = new Font("Tahoma", 9, FontStyle.Italic);
styleOdd.ForeColor = Color.Blue;
XLStyle styleEven = new XLStyle(book);
styleEven.Font = new Font("Tahoma", 9, FontStyle.Bold);
styleEven.ForeColor = Color.Red;
// step 3: write content and format into some cells
for (int i = 0; i < 70000; i++)
{
XLCell cell = sheet[i, 0];
cell.Value = i + 1;
cell.Style = ((i+1) % 2 == 0)? styleEven: styleOdd;
}
// step 4: save the file
string fileName = Application.StartupPath + @"\hello.xlsx";
book.Save(fileName, C1.C1Excel.FileFormat.OpenXml);
System.Diagnostics.Process.Start(fileName);
|
|