Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed May 22, 2013 12:57 pm

Hi I get the following error converting from excel,

Couldn't find information about the character. Unicode is not supported by this font.

here's the code:

Code: Select all
 try
            {
                //Load Workbook 
                Workbook workbook = new Workbook();
                workbook.LoadFromFile(sDoc);

                //Edit Text 
                Worksheet sheet = workbook.Worksheets[0];
                sheet.Range["A2"].Text = sDateFrom + " to " + sDateTo;
                sheet.Range["A4"].Text = sETPNacs;
                sheet.Range["B4"].Text = storename;
                sheet.Range["C4"].Text = sAddress1;
                sheet.Range["D4"].Text = respiratory.ToString();
                sheet.Range["E4"].Text = high_risk.ToString();
                sheet.Range["F4"].Text = post_discharge.ToString();
                sheet.Range["G4"].Text = non_target_group.ToString();
                sheet.Range["H4"].Text = medicines_prescribed.ToString();
                sheet.Range["I4"].Text = medicines_otc.ToString();                                 
                sheet.Range["J4"].Text = info_provided.ToString();                                 
                sheet.Range["K4"].Text = referral.ToString();                                 
                sheet.Range["L4"].Text = improvement1.ToString();                                 
                sheet.Range["M4"].Text = improvement2.ToString();                                 
                sheet.Range["N4"].Text = improvement3.ToString();                                 
                sheet.Range["O4"].Text = improvement4.ToString();                                 
                sheet.Range["P4"].Text = dietandnutrition.ToString();                                 
                sheet.Range["Q4"].Text = smoking.ToString();                                 
                sheet.Range["R4"].Text = physicalactivity.ToString();                                 
                sheet.Range["S4"].Text = alcohol.ToString();                                 
                sheet.Range["T4"].Text = sexualhealth.ToString();                                 
                sheet.Range["U4"].Text = weightmanagement.ToString();                                 
                sheet.Range["V4"].Text = otherhealth.ToString();                                 
                 
                //Save and Launch 
                workbook.SaveToFile(sDestDoc, ExcelVersion.Version2007);               
                System.Diagnostics.Process.Start(sDestDoc);

                //
                 PdfDocument pdfDocument = new PdfDocument(); 
                 pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape; 
                 pdfDocument.PageSettings.Width = 970; 
                 pdfDocument.PageSettings.Height = 850; 
                 PdfConverter pdfConverter = new PdfConverter(workbook); 
                 PdfConverterSettings settings = new PdfConverterSettings(); 
                 settings.TemplateDocument = pdfDocument; 
                 pdfDocument = pdfConverter.Convert(settings);
                 pdfDocument.SaveToFile(sDestDoc.Replace(".xls", ".pdf"));
                 ShowPDF(sDestDoc.Replace(".xls", ".pdf"));

            }
            catch (Exception Ex)
            {
                return Ex.Message;
            }

I have attached the spreadsheet thanks.
Attachments
MUR_Summary.rar
(5.43 KiB) Downloaded 621 times

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Thu May 23, 2013 3:28 am

Hello,

Sorry for inconvenience.

The issue is caused by there is specific font in your Excel file not embed into PDF. Please add the code EmbedFonts = true to PdfConverterSettings to ensure that all font are embed into PDF. And please try to set the size of pdfpage according to the size of the sheet in excel file, then you will get a better output. I provide you some code below as a reference.

Code: Select all
PdfDocument pdfDocument = new PdfDocument();
Worksheet sheet = workbook.Worksheets[0];

float pageWidth = 0;
for (int i = 1; i <= sheet.LastColumn;i++ )
       {
        pageWidth += (float)sheet.GetColumnWidth(i);
       }
pageWidth = pageWidth + pdfDocument.PageSettings.Margins.Left + pdfDocument.PageSettings.Margins.Right;

pdfDocument.PageSettings.Width = pageWidth;
pdfDocument.PageSettings.Margins.Bottom = 0;
PdfConverter pdfConverter = new PdfConverter(sheet);
PdfConverterSettings settings = new PdfConverterSettings();
settings.TemplateDocument = pdfDocument;

settings.EmbedFonts = true;
               
pdfDocument = pdfConverter.Convert(settings);
pdfDocument.SaveToFile(string.Format("{0}.pdf",sheet.Name));



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

Sincerely,
Gary
E-iceblue support team
User avatar

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

Thu May 23, 2013 8:49 am

That works great! thank you!

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Return to Spire.XLS

cron