Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • If the workbook formatting needs to be modified dynamically at runtime, the changes should be made in the unpopulated template before populating the data, rather than to the populated file.
  • Design the template file, load it in ExcelApplication and make any other customizations desired, then pass it on to ExcelTemplate to load in the data.
    Code Block
    // POSSIBLE CORRECT CODE:
    
    
    ExcelApplication xla = new ExcelApplication();
    Workbook wb = xla.Open(Page.MapPath(@"path\to\code.xlsx"));
    
    /*...*/
    
    ExcelTemplate xlt = new ExcelTemplate();
    
    xlt.Open(xla, wb);
    
    xlt.Process();
    xlt.Save(Page.Response, "Completed.xlsx", false);
    

...

  • Don't vaguely guess how much area a data set might take, try to narrow down the area as much as possible towards only populated data.
  • Start with the range of populated cells so you are only looping through theirs.
    Code Block
    // POSSIBLE CORRECT CODE:
    
    Area testArea = ws.CreateArea(1,1,20,4);
    
    // Create areas that are as accurately sized to the data as possible, as opposed to vastly overscaled.

...