Hi,
I have data in IList and i am trying to export the same to excel(.xls or .xlsx any one). But i am getting the exception. So if any one can put a light on it.
for (var i = 0; i < this.RowList.Count; i++)
{
for (var j = 0; j < this.Columns.Count; j++)
{
worksheet.Cells[i, j].SetValue("Test");
}
}
if (workbook != null)
{
XlsxFormatProvider formatProvider = new XlsxFormatProvider();
formatProvider.Export(workbook, stream); // Exception here
}
{System.TypeInitializationException: The type initializer for 'Telerik.Windows.Documents.Spreadsheet.Measurement.FontManager' threw an exception. ---> System.UnauthorizedAccessException: Invalid cross-thread access.
at MS.Internal.XcpImports.CheckThread()
at MS.Internal.XcpImports.Font_GetSystemGlyphTypefaces()
at System.Windows.Media.Fonts.get_SystemTypefaces()
at Telerik.Windows.Documents.Spreadsheet.Measurement.FontManager..cctor()
--- End of inner exception stack trace ---
at Telerik.Windows.Documents.Spreadsheet.Measurement.FontManager.IsMonospaced(String fontFamily)
at Telerik.Windows.Documents.Spreadsheet.Model.FontProperties.get_IsMonospaced()
at Telerik.Windows.Documents.Spreadsheet.Measurement.RadTextMeasurer.Measure(String text, FontProperties fontProperties, Nullable`1 wrappingWidth)
at Telerik.Windows.Documents.Spreadsheet.Measurement.RadTextMeasurer.MeasureMultiline(String text, FontProperties fontProperties, Nullable`1 wrappingWidth)
at Telerik.Windows.Documents.Spreadsheet.Layout.LayoutHelper.CalculateCellContentSize(ICellValue cellValue, CellValueFormat format, FontProperties fontProperties, Int32 indentFactor, Nullable`1 wrappingWidth)
at Telerik.Windows.Documents.Spreadsheet.Layout.LayoutHelper.CalculateAutoColumnWidth(Worksheet worksheet, Int32 columnIndex, Int32 fromRowIndex, Int32 toRowIndex, Boolean respectNumberValuesOnly)
at Telerik.Windows.Documents.Spreadsheet.Model.ColumnSelection.<>c__DisplayClass8.<AutoFitWidth>b__7(CellRange cellRange)
at Telerik.Windows.Documents.Spreadsheet.Model.SelectionBase.ExecuteForEachRange(IEnumerable`1 cellRanges, Action`1 action, Predicate`1 canExecute)
at Telerik.Windows.Documents.Spreadsheet.Model.SelectionBase.ExecuteForEachRangeInsideBeginEndUpdate(IEnumerable`1 cellRanges, Action`1 action, Predicate`1 canExecute)
at Telerik.Windows.Documents.Spreadsheet.Model.ColumnSelection.AutoFitWidth(Boolean expandOnly)
at Telerik.Windows.Documents.Spreadsheet.Model.CellSelection.<>c__DisplayClass1`1.<SetPropertyValue>b__0(CellRange cellRange)
at Telerik.Windows.Documents.Spreadsheet.Model.SelectionBase.ExecuteForEachRange(IEnumerable`1 cellRanges, Action`1 action, Predicate`1 canExecute)
at Telerik.Windows.Documents.Spreadsheet.Model.SelectionBase.ExecuteForEachRangeInsideBeginEndUpdate(IEnumerable`1 cellRanges, Action`1 action, Predicate`1 canExecute)
at Telerik.Windows.Documents.Spreadsheet.Model.CellSelection.SetPropertyValue[T](ICellProperty`1 property, T value)
at Telerik.Windows.Documents.Spreadsheet.Model.CellSelection.SetValueInternal(ICellValue cellValue, CellValueFormat newFormat)
at Telerik.Windows.Documents.Spreadsheet.Model.CellSelection.SetValue(String value)
at OnGuard.Connext.FrontEnd.Library.SL.ViewModel.ExportOptionsViewModel.ExportToFile()}