Guest User

Untitled

a guest
Oct 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. using (var package = new ExcelPackage(File.Create(@"C:\Temp\test.xlsx")))
  6. {
  7. var sheet = package.Workbook.Worksheets.Add("Sandbox");
  8.  
  9. var parser = new TableParser(1, 1);
  10.  
  11. parser.InsertRow += (row) => sheet.InsertRow(row, 1);
  12. parser.SetCell += (row, col, tag) => sheet.Cells[row, col].Value = tag;
  13. parser.MergeCell += (fromRow, fromCol, toRow, toCol) => sheet.Cells[fromRow, fromCol, toRow, toCol].Merge = true;
  14.  
  15. parser.Parse(@"
  16. |-------------------------------|---------------|
  17. | 1 | 11 |
  18. |---------------|---------------|---------------|
  19. | 2 | 3 | 12 |
  20. |---------------|---------------|---------------|
  21. | 4 | 5 | 13 |
  22. | |---------------| |
  23. | | 6 | |
  24. |---------------|---------------| |
  25. | 7 | 8 | |
  26. |---------------| | |
  27. | 9 | | |
  28. | |---------------| |
  29. | | 10 | |
  30. |---------------|---------------|---------------|");
  31.  
  32. parser.Seek(parser.CurrentRow + 1, 1);
  33.  
  34. parser.Parse(@"
  35. |------------------------------------------------------------------------------------|
  36. | a | | |
  37. | |----------------|----------------|----------------|----------------|
  38. | | b | c | d | e |
  39. |----------------|----------------|----------------|----------------|----------------|
  40. ");
  41.  
  42. package.Save();
  43. }
  44. }
  45. }
Add Comment
Please, Sign In to add comment