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.
Hello, Landrum.
As far as I understand, you are saying that when loading an excel file that has merged cells (that have border, fill, etc.) the igSpreadsheet is not visualizing them properly? Correct me if I'm wrong. This is functionality that is expecting to work. I see you are using the example from our samples browser. I took the following sample and just add a merged cell to the excel file and the igSpreadsheet is properly visualizing the cell, together with all its modifications.
Is this the only problem you are experiencing right now? I also cannot see the error images that you have uploaded. Please share more details about the errors you are seeing and I will help you further. Thank you in advance for cooperation!
Best regards,
Nikolay Alipiev,
Software Developer
Infragistics
It appears the issue is actually in :
headerImage.CellFormat.Fill = CellFill.CreateLinearGradientFill(90, Color.FromArgb(255, 230, 230, 230), Color.FromArgb(214, 185, 185, 185));
It appears to error out when their is a Gradient fill
Hi, Landrum.
The spreadsheet is supposed to visualize cells with gradient color. Can you tell me if the errors is on the client-side or the server-side and also some more details about the errors itself? Thank you in advance for the cooperation!
Here is a sample with our client-side excel engine, you can check it and consider if it can be useful for you.
Nikolay Alipiev
The error is Generated upon loading the workbook after it has been generated server side.
Unfortunately this error doesn't give me information and this is what I can help you with for the moment. If you have the chance to send me the error stack or more information about it I will be grateful. If you are interested in developing custom solutions based on any specific requirement, consider contacting our consulting department http://d3.infragistics.com/ . They will gladly discuss any details and the best way for implementing these for the project at hand.