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;
}
}
}
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;
}
}
}