c# - Excel file with multiple sheets from SSRS Reports -


Assume that I have 3 bytes of arrays, each representin a .xls file I give them a single XLS file with 3 sheets How can I add in SSRS reports are very rich and do not include charts objects.

Performance is not important so I can save them on disk as necessary, as the last resort, I can also use excel macros (if I knew how to do it). I tried to use microsodt.office.interop.excel, but I could manage to add a new sheet to only one file, I could not add an existing sheet

Any help would be appreciated.

Here is a method that writes a byte in the form of a letter for a specific workbook:

  Public Static Zero WriteToSheet (String Target Bookpath, Byte [] fileBytes) {try {Object x = Type.Missing; Create a temp file to encapsulate the // byte array string tmpPath = IO.Path.ChangeExtension (IO.Path.GetTempFileName (), ".xls"); My.Computer.FileSystem.WriteAllBytes (tmpPath, fileBytes, Incorrect); // Start Excel Application (COM) Excel.Application xlApp = new Excel.Application (); // Open Target Book Excel Workbook Targetbook = XLAP Works. Open (targetbooks, x, x, x, x, x, x, x, x, x, x, x, x, x, x); // Open Temp file with Excel Interop Excel Workbook Sourcebook = Xlap Works. Open (TmPath, X, X, X, X, X, X, X, X, X, X, X, X, X, X); // Receive a reference for the desired letter excel. Worksheet source sheet = (Excel Worksheet) sourceBook.Worksheets (1); // Workspace Copy the temp sheet specified in the form of the "first" parameter in Excel. Worksheet target = first (Excel.Worksheet) targetBook.Worksheets (1); Try it before {SourceSheet.Copy (target, X, X); Save // ​​Close and close the sourcebook. Close (wrong, x, x); Targetbook.Close (true, x, x); XlApp.Workbooks.Close (); XlApp.Quit (); } Hold (exception before) {Debug.Fail (ex.ToString); } Finally {// Release COM Objects / Source Source (SourceSheet); Destroy (source book); // Destination goal (first goal); Destroy (targetbook); // app destruction (xlap); } // Kill the antidote file. My.Computer.FileSystem.DeleteFile (tmpPath); } Hold (exception before) {Debug.Fail (ex.ToString); }}  

The DESTROY method releases COM stuff, which is very important:

  public static zero destruction (object o) {try {system. Runtime .InteropServices.Marshal.ReleaseComObject (O); } Hold (exception before) {Debug.Fail (ex.ToString); ErrorLog.Write (ex.ToString); } Finally {O = zero; }}  

If I understand correctly, then you have to:

  1. Create a new workbook
  2. Loop's Byte Arrays
  3. Call WriteToSheet for each byte array

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -