Spire.XLS for .NET is a professional Excel .NET component that can be used to any type of .NET 2.0, 3.5, 4.0 or 4.5 framework application, both ASP.NET web sites and Windows Forms application.

Mon Feb 27, 2012 10:50 pm

I get this error trying to export my workbook to PDF

Server Error in '/' Application.
--------------------------------------------------------------------------------

Culture is not supported.
Parameter name: culture
66569 (0x10409) is an invalid culture identifier.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Globalization.CultureNotFoundException: Culture is not supported.
Parameter name: culture
66569 (0x10409) is an invalid culture identifier.

Source Error:


Line 83: settings.EmbedFonts = true;
Line 84: settings.TemplateDocument = pdfDocument;
Line 85: pdfDocument = pdfConverter.Convert(settings);
Line 86:
Line 87: byte[] fileData;


Source File: C:\Projects\AVM Solutions\Common\Helpers\PDFConverter.cs Line: 85

Stack Trace:


[CultureNotFoundException: Culture is not supported.
Parameter name: culture
66569 (0x10409) is an invalid culture identifier.]
System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride) +12562108
System.Globalization.CultureInfo.InitializeFromCultureId(Int32 culture, Boolean useUserOverride) +59
Spire.Xls.Core.FormatParser.FormatTokens.CultureToken.get_Culture() +37
Spire.Xls.Core.FormatParser.FormatSection.a(Double A_0, Boolean A_1, Int32 A_2, Int32 A_3, Boolean A_4, Boolean A_5, Boolean A_6) +638
Spire.Xls.Core.FormatParser.FormatSection.ApplyFormat(Double value, Boolean bShowReservedSymbols) +660
Spire.Xls.Core.Spreadsheet.XlsRange.get_NumberText() +940
Spire.Xls.Converter.PdfConverter.a(XlsExtendedFormat A_0, XlsRange A_1, RectangleF A_2, RectangleF A_3, PdfCanvas A_4) +775
Spire.Xls.Converter.PdfConverter.b(Worksheet A_0, MergedRegion A_1, Int32 A_2, Int32 A_3, PdfCanvas A_4, ItemSizeHelper A_5, ItemSizeHelper A_6) +594
Spire.Xls.Converter.PdfConverter.a(Worksheet A_0, Int32 A_1, Int32 A_2, Int32 A_3, Int32 A_4, PdfCanvas A_5, ItemSizeHelper A_6, ItemSizeHelper A_7, b A_8) +229
Spire.Xls.Converter.PdfConverter.a(Worksheet A_0, Int32 A_1, Int32 A_2, Int32 A_3, Int32 A_4, CellRange A_5, Single A_6, Single A_7, ItemSizeHelper A_8, ItemSizeHelper A_9) +916
Spire.Xls.Converter.PdfConverter.a(Worksheet A_0, CellRange A_1) +2894
Spire.Xls.Converter.PdfConverter.Convert() +823
AVM.AvmSolutions.Common.Helpers.PDFConverter.ExcelToPdf(Stream stream) in C:\Projects\AVM Solutions\Common\Helpers\PDFConverter.cs:85
AVM.AvmSolutions.Common.Helpers.PDFConverter.DocumentToPdf(ModuleItem moduleItem) in C:\Projects\AVM Solutions\Common\Helpers\PDFConverter.cs:36
AVM.AvmSolutions.Web.Portal.Controls.GroupModules.ModulesGrid_ItemCommand(Object sender, GridCommandEventArgs e) in C:\Projects\AVM Solutions\Web.Portal\Controls\GroupModules.ascx.cs:143
Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +64
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +102
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707


--------------------------------------------------------------------------------------------

this is the code I'm using:

private static byte[] ExcelToPdf(Stream stream)
{

var workbook = new Workbook();
workbook.LoadFromStream(stream, ExcelVersion.Version97to2003);

var pdfConverter = new PdfConverter(workbook);
var pdfDocument = new PdfDocument();
var settings = new PdfConverterSettings();
settings.EmbedFonts = true;
settings.TemplateDocument = pdfDocument;
pdfDocument = pdfConverter.Convert(settings);

byte[] fileData;
using (var pdfStream = new MemoryStream())
{
pdfDocument.SaveToStream(pdfStream);
pdfStream.Position = 0;
var binaryReader = new BinaryReader(pdfStream);
fileData = binaryReader.ReadBytes((int)pdfStream.Length);
}

return fileData;
}

pablotola
 
Posts: 1
Joined: Thu Feb 02, 2012 2:28 pm

Wed Feb 29, 2012 6:25 am

Hi pablotola,

Thanks for your feedback.

According to your description, the problem you mentioned is not caused by our product.

This may be caused by the request of your web.

Well,if you want to convert a workbook to pdf, you just need the following code:

Code: Select all
 var workbook = new Workbook();
            workbook.LoadFromStream(stream, ExcelVersion.Version97to2003);

            var pdfConverter = new PdfConverter(workbook);
            var pdfDocument = new PdfDocument();
            var settings = new PdfConverterSettings();
            settings.EmbedFonts = true;
            settings.TemplateDocument = pdfDocument;
            pdfDocument = pdfConverter.Convert(settings);

            pdfDocument.SaveToFile(Server.MapPath(@".\result.pdf"));


Please check it.

If you still have this problem, please give us more informations(what is the exactly you want to do,excel file and so on) to help us better resolve this issue.
Have a great day!

BR
Suvi
e-iceblue support
User avatar

Suvi.Wu
 
Posts: 154
Joined: Thu Oct 20, 2011 2:53 am

Mon Apr 29, 2013 2:23 pm

this script pdfDocument = pdfConverter.Convert(settings);
return error "Object reference not set to an instance of an object. "
can u help me

anggunperpatih18
 
Posts: 2
Joined: Mon Apr 29, 2013 7:50 am

Tue Apr 30, 2013 4:02 am

Hello anggunperpatih18,

Thanks for your inquiry.
The issue has not been reproduced, could you please provide us your excel file if convenience so that we can repro it and figure out the solution for you.

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu May 02, 2013 9:19 am

Hello anggunperpatih18,

Has your issue been resolved? If not, could you please provide us your excel file if convenience so that we can repro it and figure out the solution for you.

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.XLS