Loop in Excel after Spreadsheet Export

3 posts, 0 answers
  1. Bob
    Bob avatar
    7 posts
    Member since:
    Jul 2012

    Posted 14 Dec 2014 Link to this post

    After exporting a RadSpreadsheet workbook to xlsx format using XlsxFormatProvider, resulting Excel workbook opens within Excel and basic functions seem OK.  However, other simple Excel functions cause Excel to loop.  For example, right-click and select of "Format Cells ..." causes this loop behavior.

    I am using runtime UI for WPF version v4.0.30319 and Office 2010.

    Thank you!
    -----------
    namespace Xxxxx.Model

        public class ExcelService : IExcelService
        {
            private XlsxFormatProvider xlsxFormatProvider;        public ExcelService()
            {
                xlsxFormatProvider = new XlsxFormatProvider();
                WorkbookFormatProvidersManager.RegisterFormatProvider(xlsxFormatProvider);
            }

            public Workbook CreateWorkbook()
            {
                return new Workbook();
            }       

            public bool AddWorksheet(Workbook workbook, string sheetName, DataTable table)
            {
                int row;
                int col;           

                Worksheet worksheet = workbook.Worksheets.Add();
                worksheet.Name = sheetName;            
                col = 0;
                foreach (DataColumn tableColumn in table.Columns)
                {
                    worksheet.Cells[0, col].SetValue(tableColumn.Caption);
                    col++;
                }            

                row = 1;
                foreach (DataRow tableRow in table.Rows)
                {
                    col = 0;
                    foreach (DataColumn tableColumn in table.Columns)
                    {
                        worksheet.Cells[row, col].SetValue(tableRow[tableColumn].ToString());
                        //worksheet.Cells[row, col].SetFormat(new CellValueFormat("@"));
                        col++;
                    }
                    row++;
                }
                return true;
            }       

            public bool ExportWorkbook(Workbook workbook)
            {
                var dialog = new Microsoft.Win32.SaveFileDialog();
                dialog.DefaultExt = "*.xlsx";
                dialog.Filter = "Excel Workbook (*.xlsx)|*.xlsx";           
                if (dialog.ShowDialog() == true)
                {
                    using (Stream output = dialog.OpenFile())
                    {
                        xlsxFormatProvider.Export(workbook, output);
                    }
                }
                return true;
            }
        }
    }


  2. Tanya
    Admin
    Tanya avatar
    403 posts

    Posted 17 Dec 2014 Link to this post

    Hello Bob,

    We didn't manage to reproduce this issue. As it seems, the most likely reason of the crashing is the data in the worksheet. Could you try using simpler data, send us the part of the data you are trying to import or some screen cast to provide us more information for further investigation?

    Looking forward to your reply.

    Regards,
    Tanya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Bob
    Bob avatar
    7 posts
    Member since:
    Jul 2012

    Posted 17 Dec 2014 in reply to Tanya Link to this post

    Hello, Tanya,

    Thank you very much for looking at the issue.   I can forward a spreadsheet for your review, but please read the below first.

    While preparing this reply, I opened one of the XLSX files to make sure it will exhibit the same problem for you.   But it worked just fine.  I then created a new XLSX file using the same process (I'm running in Debug in Visual Studio) and STILL cannot recreate the problem.  Computer and VS have been restarted, but ZERO code changes, honest!

    This issue was consistent (several XLSX files created with the same problem) but seems to be gone now.  

    Thank you again for taking the time to consider my report.

    Bob




Back to Top