Created
September 8, 2022 23:34
-
-
Save jahav/a9c7b694b695875f455aa3698f9439d6 to your computer and use it in GitHub Desktop.
ClosedXML 1594 demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Main() | |
{ | |
var workbook = new XLWorkbook(); | |
var worksheet = workbook.Worksheets.Add("Dati"); | |
DataGenerationWithBigData(worksheet); | |
worksheet.Columns().AdjustToContents(); | |
worksheet.PageSetup.PageOrientation = XLPageOrientation.Portrait; | |
worksheet.PageSetup.PaperSize = XLPaperSize.A4Paper; | |
workbook.CalculateMode = XLCalculateMode.Auto; | |
workbook.SaveAs(@"C:\temp\file.xlsx"); | |
} | |
public static void DataGenerationWithBigData(IXLWorksheet worksheet) | |
{ | |
for (var i = 0; i < 15000; i++) | |
{ | |
for (var col = 0; col < 25; col++) | |
{ | |
worksheet.Cell(i + 1, col + 1).Value = "X"; | |
} | |
} | |
} | |
public static string ColumnIndexToColumnLetter(int colIndex) | |
{ | |
int div = colIndex; | |
string colLetter = String.Empty; | |
int mod = 0; | |
while (div > 0) | |
{ | |
mod = (div - 1) % 26; | |
colLetter = (char)(65 + mod) + colLetter; | |
div = ((div - mod) / 26); | |
} | |
return colLetter; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment