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
500
Export to Excel without manually creating the excel workbook
posted

Hi, I am using ASP.Net MVC. On Ignite UI's website , The sample contains numerous method including method that set up the columns and rows of the worksheet manually according to the grid and then the data is exported to it.

Isn't there a shorter way of exporting to Excel without manually designing the layout of the Excel Workbook? Why cant the grid provide all the column settings to the Excel Exporter,

I think in WebForms we have to write only one line like this --> this.ultraGridExcelExporter1.Export(this.ultraGrid1, "C:\\GridData.xls");

This line exports the data of the grid directly to the excel sheet without specifying manually about the columns and rows of the grid, Can we do this in Ignite UI?

Why do we have to specify like this(FROM IGNITE UI SAMPLE) :

 public void PopulateExcelWorkbook(List<Order> data)
            {
                Worksheet currentWorksheet = this.excelWorkbook.Worksheets.Add("WorkSheet1");

                foreach (var cell in currentWorksheet.GetRegion("A1:D1"))
                {
                    cell.CellFormat.Fill = CellFill.CreateSolidFill(Color.Gray);
                    cell.CellFormat.Font.ColorInfo = new WorkbookColorInfo(Color.White);
                }

                currentWorksheet.Rows[0].Cells[0].Value = "Order ID";
                currentWorksheet.Rows[0].Cells[1].Value = "Contact Name";
                currentWorksheet.Rows[0].Cells[2].Value = "Shipping Address";
                currentWorksheet.Rows[0].Cells[3].Value = "Order Date";
                
                currentWorksheet.Columns[0].Width = 3000;
                currentWorksheet.Columns[0].CellFormat.Alignment = HorizontalCellAlignment.Left;
                currentWorksheet.Columns[1].Width = 7100;
                currentWorksheet.Columns[2].Width = 3000;
                currentWorksheet.Columns[2].CellFormat.Alignment = HorizontalCellAlignment.Left;
                currentWorksheet.Columns[3].Width = 6100;

                int i = 1;
                foreach (Order order in data)
                {
                    currentWorksheet.Rows[i].Cells[0].Value = order.OrderID;
                    currentWorksheet.Rows[i].Cells[1].Value = order.ContactName;
                    currentWorksheet.Rows[i].Cells[2].Value = order.ShipAddress;
                    currentWorksheet.Rows[i].Cells[3].Value = order.OrderDate != null ? string.Format("{0:d}", order.OrderDate) : "";
                    i++;
                }
            }

Parents
No Data
Reply
  • 29417
    Verified Answer
    Offline posted

    Hello Omer,

     

    Thank you for posting in our forum.

     

    I’ve looked into this and there’s currently no method that allows the igGrid/igHierarchicalGrid to be exported with its current layout in excel.

    The current recommended approach is to export the grid’s data manually by defining the layouts and filling the data.

     

    If you wish to see such a method implemented in future version please log it as a new product idea so that it may be considered for implementation.

    You can suggest new product ideas for future versions (or vote for existing ones) at <http://ideas.infragistics.com>.

     

    Steps to create your idea:

                   

    1.       Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).

    2.       Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)

    3.       Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!

     

    The benefits of submitting the product idea yourself include:

     

    -          Direct communication with our product management team regarding your product idea.

    -          Notifications whenever new information regarding your idea becomes available.

     

    Additional benefits of the product idea system include:

     

    -          Ability to vote on your favorite product ideas to let us know which ones are the most important to you.  You will have ten votes for this and can change which ideas you are voting for at any time.

    -          Allow you to shape the future of our products by requesting new controls and products altogether.

    -          You and other developers can discuss existing product ideas with members of our Product Management team.

     

    The product ideas site allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.

     

    Let me know if you have any additional questions or concerns.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://ko.infragistics.com/support

     

Children