This is a migrated thread and some comments may be shown as answers.

Loop in Excel after Spreadsheet Export

2 Answers 195 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 15 Dec 2014, 03:46 AM
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 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 17 Dec 2014, 06:55 PM
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.

 
0
Bob
Top achievements
Rank 1
answered on 17 Dec 2014, 08:50 PM
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




Tags
Spreadsheet
Asked by
Bob
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Bob
Top achievements
Rank 1
Share this question
or