Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- using (var package = new ExcelPackage(File.Create(@"C:\Temp\test.xlsx")))
- {
- var sheet = package.Workbook.Worksheets.Add("Sandbox");
- var parser = new TableParser(1, 1);
- parser.InsertRow += (row) => sheet.InsertRow(row, 1);
- parser.SetCell += (row, col, tag) => sheet.Cells[row, col].Value = tag;
- parser.MergeCell += (fromRow, fromCol, toRow, toCol) => sheet.Cells[fromRow, fromCol, toRow, toCol].Merge = true;
- parser.Parse(@"
- |-------------------------------|---------------|
- | 1 | 11 |
- |---------------|---------------|---------------|
- | 2 | 3 | 12 |
- |---------------|---------------|---------------|
- | 4 | 5 | 13 |
- | |---------------| |
- | | 6 | |
- |---------------|---------------| |
- | 7 | 8 | |
- |---------------| | |
- | 9 | | |
- | |---------------| |
- | | 10 | |
- |---------------|---------------|---------------|");
- parser.Seek(parser.CurrentRow + 1, 1);
- parser.Parse(@"
- |------------------------------------------------------------------------------------|
- | a | | |
- | |----------------|----------------|----------------|----------------|
- | | b | c | d | e |
- |----------------|----------------|----------------|----------------|----------------|
- ");
- package.Save();
- }
- }
- }
Add Comment
Please, Sign In to add comment