Skip to content

Instantly share code, notes, and snippets.

View jahav's full-sized avatar

Jan Havlíček jahav

View GitHub Profile
@jahav
jahav / Create-1_000_000.cs
Created September 28, 2023 13:14
Create a file with 1 000 000 rows and 10 columns and print out how long it takes.
var sw = Stopwatch.StartNew();
using var wb = new XLWorkbook();
var sheet = wb.AddWorksheet();
// Lazy created data
var data = Enumerable.Range(0, 1_000_000).Select(_ =>
{
return Enumerable.Range(0, 10).Select(_ => "Hello world");
});
@jahav
jahav / ClosedXML-250_000.cs
Created September 28, 2023 13:12
Create a file with 250 000 rows and 15 columns and print out how long it takes.
var sw = Stopwatch.StartNew();
using var wb = new XLWorkbook();
var sheet = wb.AddWorksheet();
// Lazy created data
var data = Enumerable.Range(0, 250_000).Select(_ =>
{
// Always create new string, like database provider would
var text = Enumerable.Range(0, 10).Select<int, object>(_ => new string("Hello world"));
var numbers = Enumerable.Range(0, 5).Cast<object>();
@jahav
jahav / ANTLR2Rolex.cs
Created June 3, 2023 15:26
A PoC converter that converts ANTLR lexer to Rolex lexer.
using System.Text;
using Antlr4.Runtime;
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
var f = string.Join("\n", File.ReadAllLines(@"c:\Users\havli\source\repos\Antlr2Rolex\FormulaLexer.g4"));
var inputStream = new AntlrInputStream(f);
@jahav
jahav / XLTokens.rl
Created June 3, 2023 15:23
A lexer for Rolex lexer converted from ANTLR grammar.
REF_CONSTANT = '((#REF!))'
NONREF_ERRORS = '((#DIV/0!)|(#N/A)|(#NAME\?)|(#NULL!)|(#NUM!)|(#VALUE!)|(#GETTING_DATA))'
LOGICAL_CONSTANT = '((FALSE)|(TRUE))'
NUMERICAL_CONSTANT = '((((((((((((((([0-9]))))))+)))))(((((((((\.))((((((((([0-9]))))))+)))))))))?))|(((((\.))((((((((([0-9]))))))+)))))))((((((E))(((((((\+)|(\-))))))?)((((((((([0-9]))))))+))))))?)))'
STRING_CONSTANT = '(((("))((((((((((("")))|(((\u0009)|(\u000A)|(\u000D)|([\u0020-\u0021])|([\u0023-\uD7FF])|([\uE000-\uFFFD])|([\u10000-\u10FFFF])))))))(((((((((((("")))|(((\u0009)|(\u000A)|(\u000D)|([\u0020-\u0021])|([\u0023-\uD7FF])|([\uE000-\uFFFD])|([\u10000-\u10FFFF])))))))))))*))))?)(("))))'
POW = '((((((((( )|(\u000D)|(\u000A))))*)))\^((((((( )|(\u000D)|(\u000A))))*)))))'
MULT = '((((((((( )|(\u000D)|(\u000A))))*)))\*((((((( )|(\u000D)|(\u000A))))*)))))'
DIV = '((((((((( )|(\u000D)|(\u000A))))*)))/((((((( )|(\u000D)|(\u000A))))*)))))'
PLUS = '((((((((( )|(\u000D)|(\u000A))))*)))\+((((((( )|(\u000D)|(\u000A))))*)))))'
MINUS = '((((((((( )|(\u000D)|(\u00
using var wb = new XLWorkbook();
var ws = wb.AddWorksheet();
var data = Enumerable.Range(0, 500000).Select(x => new
{
One = 1,
Two = 2,
Three = 3,
Four = 3.14,
Five = true,
@jahav
jahav / test1838.cs
Created January 26, 2023 00:59
Test for issue 1838 of ClosedXML
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using ClosedXML.Excel;
namespace ConsoleApp11
{
internal class Program
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using ClosedXML.Excel;
namespace ClosedXML.Sandbox
{
@jahav
jahav / 1874-test.cs
Created December 16, 2022 22:07
Create a large file for test of issue 1874 for ClosedXML
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("A", typeof(String));
DataColumn dc2 = new DataColumn("B", typeof(String));
DataColumn dc3 = new DataColumn("C", typeof(String));
DataColumn dc4 = new DataColumn("D", typeof(String));
DataColumn dc5 = new DataColumn("E", typeof(String));
DataColumn dc6 = new DataColumn("F", typeof(String));
DataColumn dc7 = new DataColumn("G", typeof(String));
DataColumn dc8 = new DataColumn("H", typeof(String));
@jahav
jahav / Test1594.cs
Created September 8, 2022 23:34
ClosedXML 1594 demo
public void Main()
{
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Dati");
DataGenerationWithBigData(worksheet);
worksheet.Columns().AdjustToContents();
worksheet.PageSetup.PageOrientation = XLPageOrientation.Portrait;
@jahav
jahav / ClosedXml-CalcEngine-Benchamark.cs
Created September 4, 2022 17:02
A benchmark used during testing of revamped CalcEngine
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using ClosedXML.Excel;
using NUnit.Framework;
namespace ClosedXML.Sandbox
{
[TestFixture]
[RPlotExporter]