Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
Load Workbook created in C# Excel Engine
posted

I have created a workbook using the c# infragistics excel engine, I have tried several methods to populate the igSpreadsheet with the workbook.

my Controller:

public void GetReport()
   {
                    var test= ReportHelper.GetRentRollExcel(new RentRollExcel
               {
                   CurrentDatePicker =  DateTime.UtcNow,
                   Id = 9,
                   SendForDownload = false
               }, _db, Server.MapPath("~"), Url, false);
 
       Response.Clear();
       Response.AppendHeader("content-disposition""attachment; filename=" + test.FileName);
       Response.ContentType = "application/octet-stream";
       test.Workbook.Save(Response.OutputStream);
       Response.End();
   }
  

 public FileContentResult GetReport2()
   {
 
 
       MemoryStream fs = new MemoryStream();
       var test = ReportHelper.GetRentRollExcel(new RentRollExcel
       {
           CurrentDatePicker = DateTime.UtcNow,
           Id = 9,
           SendForDownload = false
       }, _db, Server.MapPath("~"), Url, false);
 
      
       test.Workbook.Save(fs);
 
       return new FileContentResult(fs.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
 
   }

public string GetReport3()
     {
 
 
         MemoryStream fs = new MemoryStream();
         var test = ReportHelper.GetRentRollExcel(new RentRollExcel
         {
             CurrentDatePicker = DateTime.UtcNow,
             Id = 9,
             SendForDownload = false
         }, _db, Server.MapPath("~"), Url, false);
 
 
         test.Workbook.Save(fs);
         return BitConverter.ToString(fs.ToArray());
         return Convert.ToBase64String(fs.ToArray());
         
     }

Obviously I have tried different ways to accomplish this: In the Java Script I have:

tried the following:

         $.ig.loader({
        scriptPath: "/Scripts/Infragistics/",
        cssPath: "/Content/InfragisticsCSS/css",
        resources: "igSpreadsheet, igExcel.LoadSaveXlsx, igExcel.LoadSaveXls, igExcel.Functions",
        ready: function() {
                    //Initializing igSpreadsheet
            $("#spreadsheet").igSpreadsheet({
                height: "600",
                width: "100%",
                isFormulaBarVisible: false,
                allowAddWorksheet: false,
                allowDeleteWorksheet: false
            });
            var workbook = null;
            var xhr = new XMLHttpRequest();
            xhr.open('GET''@Url.Action("GetReport3""Reports")'true);
            xhr.responseType = 'blob';
 
            xhr.onload = function (e) {
                        // response is unsigned 8 bit integer
 
                var fileReader = new FileReader();
 
 
                fileReader.onload = function (e) {
 
                  
                    var buffer = new Uint8Array(fileReader.result);
                    $.ig.excel.Workbook.load(buffer,
                        function(arg) {
                            workbook = arg;
                            setInitialSettings();
                        },
                        function() {
                            console.log("fail");
                        });
                }
                fileReader.readAsArrayBuffer(this.response);
 
 
            };
            xhr.send();
 
        }
    });
 
 
    $('#CompanyEntityId').selectize();
 
 
})

//Another ATTEMPT
          $.ig.loader({
              scriptPath: "/Scripts/Infragistics/",
              cssPath: "/Content/InfragisticsCSS/css",
              resources: "igSpreadsheet, igExcel.LoadSaveXlsx, igExcel.LoadSaveXls, igExcel.Functions",
              ready: function() {
                    //Initializing igSpreadsheet
                  $("#spreadsheet").igSpreadsheet({
                      height: "600",
                      width: "100%",
                      isFormulaBarVisible: false,
                      allowAddWorksheet: false,
                      allowDeleteWorksheet: false
                  });
                  var workbook = null;
                  var xhr = new XMLHttpRequest();
                  xhr.open('GET''@Url.Action("GetReport""Reports")'true);
                  xhr.responseType = 'blob';
 
                  xhr.onload = function(e) {
                        // response is unsigned 8 bit integer
 
                      var fileReader = new FileReader();
 
 
                      fileReader.onload = function(e) {
                          var buffer = new Uint8Array(fileReader.result);
                          $.ig.excel.Workbook.load(fileReader.result,
                              function(arg) {
                                  workbook = arg;
                                  setInitialSettings();
                              },
                              function() {
                                  console.log("fail");
                              });
                      }
                      fileReader.readAsArrayBuffer(this.response);
 
 
                  };
                  xhr.send();
 
              }
          });
 
 
          $('#CompanyEntityId').selectize();
 
 
      });

            //Another ATTEMPT
    $.ig.loader({
        scriptPath: "/Scripts/Infragistics/",
        cssPath: "/Content/InfragisticsCSS/css",
        resources: "igSpreadsheet, igExcel.LoadSaveXlsx, igExcel.Functions",
        ready: function() {
                    //Initializing igSpreadsheet
            $("#spreadsheet").igSpreadsheet({
                height: "600",
                width: "100%",
                isFormulaBarVisible: false,
                allowAddWorksheet: false,
                allowDeleteWorksheet: false
            });
 
            $.ajax({
                url: '@Url.Action("GetReport3","Reports")',
              
                success: function(data) {
                    var responseArray = new Uint8Array(data);
                    var book = $.ig.excel.Workbook.load(data,
                        function(err, workbook) {
                            workbook = arguments[0];
                           
                        },
                        function() {
                            console.log("fail");
                        });
 
                    $("#spreadsheet").igSpreadsheet("option""workbook", workbook);
                },
                error: function() {
                    createError('errorMessage''type');
                },
                complete: function() {
 
                }
            });
 
        }
    });
 
 
    $('#CompanyEntityId').selectize();
 
 
});

I either get one of two messages:

or 




****UPDATE****
It appears that the problem lies with Merged Cells You can Merge cells but when you add any value to them, Borders,fills,text, formulas the IgSpreadsheet will not read them.

excel file.zip
Parents Reply Children