As the client of E-iceblue, you probably want to know "what can it do" or "how to use it". To learn about the answers to these questions,please read the instructions on each product page or view the online tutorials. Listed below are answers to a few of the most popular questions you might have.


If you can't find the answer to your question, please contact us via support@e-iceblue.com or post it to our forum, and share following details for investigation purposes:

  • The input document you were testing and the output document from your side.
  • The StackTrace of the exception you were getting.
  • The code that is causing the issue.
  • What version of our product are you using?
  • What environment are you running on? OS (Windows Version) and Architecture (32 / 64 bit).
  • Spire.Doc
    How to get text from word document?
    A : You can call the method method document.GetText() to do so. Full code:
    Document document = new Document();
    document.LoadFromFile(@"..\..\test.docx");
    using (StreamWriter sw = File.CreateText("output.txt"))
     {
     sw.Write(document.GetText());
     }
    
    How to insert an image with specified height and width?
    A : You can set the properties height and width of DocPicture to resize the image. Full code:
    Document document = new Document();
    document.LoadFromFile("sample.docx", FileFormat.Docx);
    Image image = Image.FromFile("image.jpg");
    
    //specify the paragraph
    Paragraph paragraph = document.Sections[0].Paragraphs[2];
    DocPicture picture = paragraph.AppendPicture(image);
    
    //resize the image
    picture.Height = picture.Height * 0.8f;
    picture.Width = picture.Width * 0.8f;
    document.SaveToFile("result.docx", FileFormat.Docx);
    
    How to align text in word document?
    A : Please set the property HorizontalAlignment of the paragraph to align text. Full code:
    Document document = new Document();
    document.LoadFromFile("sample.docx");
    
    //set paragraph1 to align left
    Paragraph paragraph1 = document.Sections[0].Paragraphs[0];
    paragraph1.Format.HorizontalAlignment = HorizontalAlignment.Left;
    
    //set paragraph2 to align center
    Paragraph paragraph2 = document.Sections[0].Paragraphs[1];
    paragraph2.Format.HorizontalAlignment = HorizontalAlignment.Center;
    
    //set paragraph3 to align right
    Paragraph paragraph3 = document.Sections[0].Paragraphs[2];
    paragraph3.Format.HorizontalAlignment = HorizontalAlignment.Right;
    document.SaveToFile("result.docx");
    
    How to change text on existing bookmarks?
    A : You can use BookmarksNavigator to locate the specified bookmark. Then please call the method ReplaceBookmarkContent to replace text on bookmarks. Full code:
    Document document = new Document();
    document.LoadFromFile("sample.doc");
    BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
    bookmarkNavigator.MoveToBookmark("mybookmark");
    
    //replace text on bookmarks
    bookmarkNavigator.ReplaceBookmarkContent("new context", false);
    document.SaveToFile("result.doc", FileFormat.Doc);
    
    How to convert word to html?
    A : You can just call the method SaveToFile with specified file format HTML to convert word document to html. Full code:
    Document document = new Document();
    document.LoadFromFile("sample.doc");
    
    //save word document as html file
    document.SaveToFile("result.html", FileFormat.Html);
    document.Close();
    
    How to convert html to word document?
    A : Please call the method LoadFromFile to load html file. Then call the method SaveToFile to convert html to word document. Full code:
    Document document = new Document();
    
    document.LoadFromFile("sample.html", FileFormat.Html, XHTMLValidationType.None);
    //save html as word document
    document.SaveToFile("result.doc");
    document.Close();
    
    How to convert word2007 to word2003?
    A : Just call the method SaveToFile with specified file format doc to convert word2007 to word2003. Full code:
    Document document = new Document("word2007.docx");
    
    //convert word2007 to word2003
    document.SaveToFile("word2003.doc", FileFormat.Doc);
    document.Close();
    
    How to replace and delete header or footer in word document?
    A : Please use Section to get header or footer. And you can call the method Replace to replace header and call the method Clear to remove the headers or footers of the word document.
    Document document = new Document();
    Section section = document.AddSection();
    
    //add a header
    HeaderFooter header = section.HeadersFooters.Header;
    Paragraph headerParagraph = header.AddParagraph();
    TextRange text = headerParagraph.AppendText("Demo of Spire.Doc");
    text.CharacterFormat.TextColor = Color.Blue;
    document.SaveToFile("DocWithHeader.doc");
    
    //replace the header
    headerParagraph.Replace("Demo", "replaceText", true, true);
    document.SaveToFile("DocHeaderReplace.doc");
    document.LoadFromFile("DocWithHeader.doc");
    
    //delete the heater
    document.Sections[0].HeadersFooters.Header.Paragraphs.Clear();
    document.SaveToFile("DocHeaderDelete.doc");
    
    How to merge word documents?
    A : Please call the method Clone to copy a section. Then call the method Add to add the copy of the section to specified document. Full code:
    Document document1 = new Document();
    document1.LoadFromFile("merge1.docx");
    Document document2 = new Document();
    document2.LoadFromFile("merge2.docx");
    
    //add sections from document1 to document2
    foreach (Section sec in document2.Sections)
    {
        document1.Sections.Add(sec.Clone());
    }
    document1.SaveToFile("result.docx");
    
    How to traverse the cells of a table in a word document?
    A : Rows is the collection of rows in a table and Cells is the collection of cells in a row. So you can traverse cells of a table using two loops. Full code:
    Document document = new Document();
    document.LoadFromFile("sample.docx");
    Spire.Doc.Interface.ITable table = document.Sections[0].Tables[0];
    int i=0;
    
    //traverse the cells
    foreach (TableRow row in table.Rows)
    {
        foreach (TableCell cell in row.Cells)
        {
            i++;
        }
    }
    
    How to set text with shadow?
    A : You just need to set the property IsShadow of TextRange. Full code:
    Document document = new Document();
    Section section = document.AddSection();
    Paragraph paragraph = section.AddParagraph();
    TextRange HText = paragraph.AppendText("this is a test!");
    
    //set the property IsShadow
    HText.CharacterFormat.IsShadow = true;
    HText.CharacterFormat.FontSize = 80;
    document.SaveToFile("result.doc");
    
    How to insert line numbers in the Word?
    A : You need to set the properties LineNumberingRestartMode, LineNumberingStep, LineNumberingStartValue of the section to insert line numbers in word document. Full code:
    Document document = new Document();
    Section section = document.AddSection();
    
    //insert line numbers
    section.PageSetup.LineNumberingRestartMode = LineNumberingRestartMode.RestartPage;
    section.PageSetup.LineNumberingStep = 1;
    section.PageSetup.LineNumberingStartValue = 1;
    Paragraph paragraph = section.AddParagraph();
    paragraph.AppendText("As an independent Word .NET component, Spire.Doc for .NET doesn't need Microsoft Word to be installed on the machine. However, it can incorporate Microsoft Word document creation capabilities into any developers .NET applications.");
    document.SaveToFile("result.doc");
    
    How to Make Text around image?
    A : You need to set the properties TextWrappingStyle and ShapeHorizontalAlignment of the picture. Full code:
    Document document = new Document();
    Section section = document.AddSection();
    Paragraph paragraph = section.AddParagraph();
    string str = "As an independent Word .NET component, Spire.Doc for .NET doesn't need Microsoft Word to be installed on the machine. However, it can incorporate Microsoft Word document creation capabilities into any developers.NET applications.As an independent Word .NET component, Spire.Doc for .NET doesn't need Microsoft Word to be installed on the machine. However, it can incorporate Microsoft Word document creation capabilities into any developers’.NET applications.";
    paragraph.AppendText(str);
    DocPicture picture = paragraph.AppendPicture(Image.FromFile("logo.png"));
    picture.TextWrappingStyle = TextWrappingStyle.Tight;
    picture.HorizontalAlignment = ShapeHorizontalAlignment.Center;
    document.SaveToFile("result.doc");
    
    How to edit existing table in word document?
    A : Use Section to get the table and you can edit the text in a cell and you can insert new row into the table. Full code:
    Document doc = new Document("sample.docx");
    Section section = doc.Sections[0];
    ITable table = section.Tables[0];
    
    //edit text in a cell
    TableCell cell1 = table.Rows[1].Cells[1];
    Paragraph p1 = cell1.Paragraphs[0];
    p1.Text = "abc";
    
    TableCell cell2 = table.Rows[1].Cells[2];
    Paragraph p2 = cell2.Paragraphs[0];
    p2.Items.Clear();
    p2.AppendText("def");
    
    TableCell cell3 = table.Rows[1].Cells[3];
    Paragraph p3 = cell3.Paragraphs[0];
    (p3.Items[0] as TextRange).Text = "hij";
    
    //insert new row
    TableRow newRow = table.AddRow(true, true);
    foreach (TableCell cell in newRow.Cells)
    {
        cell.AddParagraph().AppendText("new row");
    }
    doc.SaveToFile("result.doc");
    
    How to set the format of hyperlink with no underline?
    A : Please set the textRange node of Hyperlink field to format hyperlink. Full code:
    Document document = new Document();
    Section section = document.AddSection();
    Paragraph paragraph = section.AddParagraph();
    Field hyperlink = paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
    TextRange text = hyperlink.NextSibling.NextSibling as TextRange;
    text.CharacterFormat.Bold = true;
    text.CharacterFormat.UnderlineStyle = UnderlineStyle.None;
    document.SaveToFile("result.doc");
    
    How to set word document read-only?
    A : Please call the method Protect to set the ProtectionType. Full code:
    Document document = new Document();
    document.LoadFromFile("sample.docx");
    document.Protect(ProtectionType.AllowOnlyReading);
    document.SaveToFile("result.doc");
    
  • Spire.XLS
    How to add an Image into Excel?
    A : Please call the method Add to add an image into a worksheet of Excel file. Full code:
    Workbook workbook = new Workbook();
    Worksheet sheet = workbook.Worksheets[0];
    
    //insert the picture day.jpg into the sheet and place it in the cell "B3"
    sheet.Pictures.Add(3, 2, "day.jpg");
    workbook.SaveToFile("result.xlsx");
    
    How to Insert a new Row into a worksheet of a Excel file?
    A : Please call the method InsertRow to add a new row into a worksheet of Excel fils. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    Worksheet sheet = workbook.Worksheets[0];
    
    //add a new row in the third row
    sheet.InsertRow(3);
    workbook.SaveToFile("result.xlsx");
    
    How to set print area in XLS?
    A : You can set the PrintArea property of the worksheet to do so. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    Worksheet sheet = workbook.Worksheets[0];
    
    //set print area from cell "B2" to cell "F8"
    sheet.PageSetup.PrintArea = "B2:F8";
    workbook.SaveToFile("result.xlsx");
    
    How to Copy Cells with formatting?
    A : Spire.XLS provides you a method called Copy to copy cells with formatting. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    Worksheet sheet1 = workbook.Worksheets[0];
    Worksheet sheet3 = workbook.Worksheets[2];
    
    //copy cell "B2" in sheet1 to cell "C6" in sheet3
    sheet1.Range[3, 2].Copy(sheet3.Range[6,3]);
    workbook.SaveToFile("result.xlsx");
    
    How to Convert XLS to PDF?
    A : First you need to add reference Spire.Pdf and Spire.Common to your project. Then creat an instance of PdfDocument and a PDF converter object . At last, call the method Convert to convert XLS to PDF. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    PdfConverter pdfConverter = new PdfConverter(workbook);
    PdfDocument pdfDocument = new PdfDocument();
    
    //settings of result PDF docement
    pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
    pdfDocument.PageSettings.Width = 970;
    pdfDocument.PageSettings.Height = 850;
    PdfConverterSettings settings = new PdfConverterSettings();
    settings.TemplateDocument = pdfDocument;
    
    //convert XLS to PDF using PdfConverter
    pdfDocument = pdfConverter.Convert(settings);
    pdfDocument.SaveToFile("result.pdf");
    
    How to merge cells in XLS?
    A : Spire.XLS provides you a method called Merge to merge cells in XLS. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    Worksheet sheet = workbook.Worksheets[0];
    
    //merges cells "B3" "B4"
    sheet.Range["B3:B4"].Merge();
    workbook.SaveToFile("result.xlsx");
    
    How to rearrange the worksheets in XLS file?
    A : Spire.XLS provides you a method called MoveWorksheet to rearrange the worksheets in XLS file? Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    Worksheet sheet = workbook.Worksheets[3];
    
    //move the fourth worksheet sheet to the first position of the worksheets
    sheet.MoveWorksheet(0);
    workbook.SaveToFile("result.xlsx");
    
    How to delete columns in excel worksheet?
    A : Spire.XLS provides you a method called DeleteColumn to delete columns. This method affect the order of the collection of worksheet immediately. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    
    Worksheet sheet = workbook.Worksheets[1];
    //delete the second column
    sheet.DeleteColumn(2);
    
    //delete the fourth column
    sheet.DeleteColumn(3);
    workbook.SaveToFile("result.xlsx");
    
    How to set number format in specified range in XLS?
    A : You can use the property NumberFormat of the destination cell to format the NumberValue of cellrange. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample.xlsx");
    Worksheet sheet = workbook.Worksheets[0];
    
    //set number format in specified range
    sheet.Range[2, 2, 6, 6].NumberFormat = "$#,##0.00";
    sheet.Range["C3"].NumberValue = 3240.689;
    sheet.Range["D4"].NumberValue = 5230.123;
    workbook.SaveToFile("result.xlsx");
    
    How to add a formula to a cell?
    A : Just set the Formula property of the cell to add a formula. Full code:
    Workbook workbook = new Workbook();
    Worksheet worksheet = workbook.Worksheets[0];
    
    //add formula =IF(H7>0,(IF(F7 > 0,(H7-F7)/F7,"""")),"""") to cell "J7"
    string formula = @"=IF(H7>0,(IF(F7 > 0,(H7-F7)/F7,"""")),"""")";
    worksheet.Range["J7"].Formula = formula;
    worksheet.Range["F7"].NumberValue = 5;
    worksheet.Range["H7"].NumberValue = 4;
    workbook.SaveToFile("result.xlsx", ExcelVersion.Version2007);
    
    How to merge multiple workbooks?
    A : Spire.XLS provides you a method called AddCopy to merge Excel files. Full code:
    Workbook workbook = new Workbook();
    workbook.LoadFromFile("sample1.xlsx");
    Workbook workbookDest = new Workbook();
    workbookDest.LoadFromFile("sample2.xlsx");
    
    //merge workbook with workbookDest
    workbookDest.Worksheets.AddCopy(workbook.Worksheets);
    workbookDest.SaveToFile("result.xlsx");
    
  • Spire.PDF
    How to convert HTML code to PDF?
    A : Spire.PDF cannot load a string containing html code. But Spire.Doc can load that and Spire.Doc supports PDF format. So you can use Spire.Doc to do the job. Full code:
    string htmlstring = "<!DOCTYPE html><html><body><h1>Header 1</h1><p>First paragraph</p></body></html>";
    Document doc = new Document();
    Section sec = doc.AddSection();
    Paragraph para = sec.AddParagraph();
    
    //add html code to document
    para.AppendHTML(htmlstring);
    
    //save document as PDF format
    doc.SaveToFile("result.pdf", FileFormat.PDF);
    
    How to embed another table in a cell of a table?
    A : Table is a simpler grid. In grid, you can manipulate each cell, set different style for each cell and embed another grid. So you can use grid to do the job. Full code:
    PdfDocument document = new PdfDocument();
    PdfPageBase page = document.Pages.Add(PdfPageSize.A4);
    
    PdfGrid grid = new PdfGrid();
    grid.Columns.Add(1);
    grid.Columns[0].Width = page.Canvas.ClientSize.Width;
    PdfGridRow row0 = grid.Rows.Add();
    row0.Cells[0].Value = "This is the first row.";
    row0.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
    PdfGridRow row1 = grid.Rows.Add();
    PdfLayoutResult result=grid.Draw(page, new PointF(0, 20));
    
    PdfGrid grid2 = new PdfGrid();
    grid2.Columns.Add(2);
    PdfGridRow newrow = grid2.Rows.Add();
    grid2.Columns[0].Width = grid.Columns[0].Width / 2;
    grid2.Columns[1].Width = grid.Columns[0].Width / 2;
    newrow.Cells[0].Value = "This is row two column one.";
    newrow.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
    newrow.Cells[1].Value = "This is row two column two.";
    newrow.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
    
    //assign grid2 to row1
    row1.Cells[0].Value = grid2;
    
    //drwa grid2
    result = grid2.Draw(page, new PointF(0, result.Bounds.Location.Y + result.Bounds.Height));
    document.SaveToFile("result.pdf");
    
    How to merge cells in grid?
    A : Spire.PDF provides you properties called RowSpan and ColumnSpan to merge cells. Full code:
    PdfDocument doc = new PdfDocument();
    PdfPageBase page = doc.Pages.Add();
    
    PdfGrid grid = new PdfGrid();
    grid.Columns.Add(5);
    float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);
    for (int i = 0; i < grid.Columns.Count; i++)
    {
        grid.Columns[i].Width = width * 0.20f;
    }
    PdfGridRow row0 = grid.Rows.Add();
    PdfGridRow row1 = grid.Rows.Add();
    
    row0.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold), true);
    row1.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Italic), true);
    
    row0.Cells[0].Value = "Corporation";
    
    //merge with the downside cell
    row0.Cells[0].RowSpan = 2;
    
    row0.Cells[1].Value = "B&K Undersea Photo";
    row0.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
    
    //merge with the right cell
    row0.Cells[1].ColumnSpan = 3;
    
    row0.Cells[4].Value = "World";
    row0.Cells[4].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold | FontStyle.Italic), true);
    row0.Cells[4].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
    row0.Cells[4].Style.BackgroundBrush = PdfBrushes.LightGreen;
    
    row1.Cells[1].Value = "Diving International Unlimited";
    row1.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
    row1.Cells[1].ColumnSpan = 4;
    
    grid.Draw(page, new PointF(0, 0));
    
    doc.SaveToFile("result.pdf");
    
    How to add signature to a PDF file?
    A : First, create a certificate instance using class PdfCertificate. The certificate instance will be used in creating a PdfSignature instance. Then create a signature instance using class PdfSignature. And you need to set the properties of the signature instance. Full code:
    PdfDocument doc = new PdfDocument();
    doc.LoadFromFile("sample.pdf");
    PdfCertificate cert = new PdfCertificate("Demo.pfx", "e-iceblue");
    
    //add signature to every page of PDF file
    foreach (PdfPageBase page in doc.Pages)
    {
        PdfSignature signature = new PdfSignature(page.Document, page, cert, "demo");
        signature.ContactInfo = "Harry";
        signature.Certificated = true;
        signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
    }
    
    doc.SaveToFile("result.pdf");
    
    How to rearrange the pages of a PDF file?
    A : Please call the method ReArrange. The method takes an int array as parameter. The int array represents the new order of the pages. Full code:
    PdfDocument document = new PdfDocument();
    
    //sample.pdf has four pages
    document.LoadFromFile("sample.pdf");
    
    //rearrange the pages of the PDF file
    int[] range = new int[] { 0, 2, 1, 3 };
    document.Pages.ReArrange(range);
    document.SaveToFile("result.pdf");
    
    How to add image watermark?
    A : Spire.PDF don't support image watermark directly. But you can set an image as BackgroundImage. If the image is big enough, the BackgroundImage will be like image watermark. Full code:
    PdfDocument document = new PdfDocument();
    PdfPageBase page = document.Pages.Add(PdfPageSize.A4);
    page.Canvas.DrawString("This is a demo about image watermark!",
                            new PdfFont(PdfFontFamily.Helvetica, 25f),
                            new PdfSolidBrush(Color.Green),
                            10, 40);
    
    //set image as BackgroundImage to make image watermark
    Image img = Image.FromFile("scene.bmp");
    page.BackgroundImage = img;
    document.SaveToFile("result.pdf");
    
    How to repeat header on all pages?
    A : Things in PdfDocumentTemplate will apply to every page of the PDF file. All you have to do is to create a method that add header to PdfDocumentTemplate. Then header will be added to every page. Full code:
    static void Main(string[] args)
    {
        PdfDocument doc = new PdfDocument();
        PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
        PdfMargins margin = new PdfMargins();
        margin.Top = unitCvtr.ConvertUnits(3.0f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
        margin.Bottom = margin.Top;
        margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
        margin.Right = margin.Left;
    
        // create three page
        PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin);
        page = doc.Pages.Add(PdfPageSize.A4, margin);
        page = doc.Pages.Add(PdfPageSize.A4, margin);
    
        //apply template
        SetDocumentTemplate(doc, PdfPageSize.A4, margin);
        doc.SaveToFile("result.pdf");
    
    }
    //method to add header to every page
    private static void SetDocumentTemplate(PdfDocument doc, SizeF pageSize, PdfMargins margin)
    {
        PdfPageTemplateElement leftSpace
            = new PdfPageTemplateElement(margin.Left, pageSize.Height);
        doc.Template.Left = leftSpace;
    
        PdfPageTemplateElement topSpace
            = new PdfPageTemplateElement(pageSize.Width, margin.Top);
        topSpace.Foreground = true;
        doc.Template.Top = topSpace;
    
        //draw header label
        PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 9f, FontStyle.Italic));
        PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Right);
        String label = "Demo about Header Repeating";
    
        //set the header style
        SizeF size = font.MeasureString(label, format);
        float y = topSpace.Height - font.Height - 40;
        PdfPen pen = new PdfPen(Color.Black, 0.75f);
        topSpace.Graphics.SetTransparency(0.5f);
        topSpace.Graphics.DrawLine(pen, margin.Left - 30, y, pageSize.Width - margin.Right + 30, y);
        y = y - 1 - size.Height;
        topSpace.Graphics.DrawString(label, font, PdfBrushes.Black, pageSize.Width - margin.Right, y, format);
    
        PdfPageTemplateElement rightSpace
            = new PdfPageTemplateElement(margin.Right, pageSize.Height);
        doc.Template.Right = rightSpace;
    
        PdfPageTemplateElement bottomSpace
            = new PdfPageTemplateElement(pageSize.Width, margin.Bottom);
        bottomSpace.Foreground = true;
        doc.Template.Bottom = bottomSpace;
    }
    
  • Spire.DataExport
    How to add picture in spreadsheets?
    A : You can add pictures to result excel files with the following code:
    CellImage img1 = new CellImage();
    img1.Column = 1;
    img1.PictureName = "demo";
    img1.Row = 1;
    cellExport1.Images.Add(img1);
    
    CellPicture pic1= new CellPicture();
    pic1.FileName = "C:\\demo.gif";
    pic1.Name = "demo";
    cellExport1.Pictures.Add(pic1);
    
    cellExport1.SaveToFile();
    
    Discuss here
    The PDF export tool to me is a cool product. But I have couple of things that I am stuck and the help document is of no help at all. What I am trying to accomplish wit the PDF export is the following.
    How do I add Titles?
    A : Add titles with the following code.
    pdfExport1.Header.Add("Spire.DataExport Headers");
    
    How do I set the Page Numbers?
    A : The Spire.DataExport produces page number automatically, You can't set page number in current version.
    How do I add the Column Headers?
    A : The Spire.DataExport procedures column headers automatically, according your set datasource.
    Page Size (Landscape or Portrait)
    A : Set page size with following code.
    pdfExport1.PDFOptions.PageOptions.Orientation = Spire.DataExport.Common.PageOrientation.Landscape;
    
    Can I use Microsoft Application Blocks to get the data and then set the DataSource to a DataTable? Currently I am getting an error.
    A : If you set the Datasource to a DataTable , You need to set DataTable property to a datatable instance.
    Discuss here
    While exporting to excel, Is there a way to restrict the format for date columns like 'dd\mm\yy'. And should not allow user to enter any other format on the excel.
    A : If you want to set data format on a column, You need to write code in GetDataParams event. Try to use the following example code:
    private void cellExport1_GetDataParams(object sender, Spire.DataExport.EventArgs.DataParamsEventArgs e)
    {
          if (e.Col == 1)
          {
                e.FormatText = "dd/MM/yy";
          }
    }
    
    Discuss here
    Is there any possibility for export HTML document to PDF?
    A : Spire.DataExport can export data into html, excel, PDF document, etc, If you want export HTML document to PDF, you need to parse the html file and export data to PDF by Spire.DataExport.
    Discuss here
    Looking at the product for possible purchase but have not been able to determine how the change/modify the attributes for a given column. That is we may have rows in which we have an output column that needs a different precison then the column next to it, or we have a string/text output column that has a length/size that is different then the source data.
    A : You can set ColumnsPrecision property value to change length and precision of column.
    Format: ColumnName=Length,Precision
    example: PartNo=8,2
    
    Discuss here
    One of my collegues gave me your dataexport module to integrate into a project. However i'm not seeing the possibillity to export a datalist and a created image. Is this possible?
    A : You can export datalist and a created image to excel file, for more detailed, please see example with installation.
    Discuss here
    I'm doing an export to excel but my date is not displayed as a date. the correct date is in there but as a number. If i change the properties of the field, i will get the correct date. How can i fix this?
    The code:
    Spire.DataExport.XLS.CellExport exp = new Spire.DataExport.XLS.CellExport();
    exp.DataFormats.CultureName = "nl-NL";
    exp.DataFormats.Float = "#,###,##0.00";
    [b]exp.DataFormats.DateTime = "dd-MM-yyyy";[/b]
    exp.DataFormats.Currency = "
    
    A : You need to add getParams event to CellExport library, Try to using following source code:
    private void cellExport1_GetDataParams(object sender, Spire.DataExport.EventArgs.DataParamsEventArgs e)
            {
                if (e.Col == 1)
                {
                    e.FormatText = "YYYY-MM-DD";
                }
            }
    
    Discuss here
    Is it possible to set the export to Tab Delimited?
    A : Please try to using following source code:
    txtExport1.CSVOption.Separator = "\tab";
    
    Discuss here
    I'm getting quite used to working with your product, but one thing i'm still not capable of getting it done. I'm working on a project that is using a huge collection of AJAX and the scriptmanager. Since the scriptmanager doesn't really like the use of Respons, the SaveToHttpResponse is not working. Is there any other solution to create the effect that the user can download the file directly?
    Is it possible to push the savetoHttpResponse to a popup and download the data from there?
    Is it possible to save to stream and add the stream in my updatepanel so the download will be activated?
    A : We recommend that you can iframe to link a aspx page, so you can use savetoreponse methd to download file.
    Discuss here
    We are thinking about purchasing this control, however we are planning on performing large data dumps into csv files using this control, we are looking at around 100k rows from a data table. Has anyone used this DataExport tool to dump this large of data into a file and if so how was the speed issue, canyou give an approximate time of how long it took?
    A : This is related to the performance test machines, spent mainly in the implementation of the writing on the document.
    Discuss here
    When I try to export a DataTable containing a DateTime field to Excel, it is shown as a number. The number is a correct value when shown as DateTime, but the cell format should be DateTime instead of Default. The DataTable correctly contains the column as DateTime.
    Here is a code snippet that reproduces the issue:
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = new SqlConnection(/* Insert some SQL Server connection string */);
    cmd.CommandText = "SELECT CAST('2010-01-01 0:00' AS DATETIME)";
    cmd.CommandType = CommandType.Text;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    DataTable table = new DataTable();
    da.Fill(table);
    CellExport ce = new CellExport();
    ce.DataTable = table;
    ce.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
    ce.SaveToHttpResponse("test.xls", Response);
    
    The resulting Excel sheet contains the following data:
    Column1
    40179
    We consider purchasing Spire.DataExport, but I need to make this work... Please help.
    A : Please try to using following way, add GetDataParams event to Spire.DataExport.
       private void cellExport1_GetDataParams(object sender, Spire.DataExport.EventArgs.DataParamsEventArgs e)
       {
                    //e.sheet equals sheet index, e.col equals column index. 
       if    ((e.Sheet == 0) && (e.Col == 6))
       {
          e.FormatText = cellExport1.DataFormats.DateTime;
       }
    }
    
    Discuss here
    Is it possible with your Controls to convert a xlsx files to a pdf with only printing and 128bit security.
    A : Yes, you can convert Excel File to PDF just need to do two steps:
    1. use OleDbConnection to open the Excel file as a DataSource
    2. use Spire.DataExport to export the data to a PDF file.
    The method following is a sample, the Excel file D:\temp\DatatableSample.xls is a test file in my computer.
    static void ConvertExcelToPDF()
    {
    OleDbConnection conn = new OleDbConnection();
    conn.ConnectionString
    = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\DatatableSample.xls;Extended Properties=""Excel 8.0""";
    
    OleDbCommand command = new OleDbCommand();
    command.CommandText = "select * from [country$A1:E19]";
    command.Connection = conn;
    conn.Open();
    
    Spire.DataExport.PDF.PDFExport pdfExport1 = new Spire.DataExport.PDF.PDFExport();
    pdfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
    pdfExport1.DataFormats.CultureName = "en-US";
    pdfExport1.DataFormats.Currency = "c";
    pdfExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
    pdfExport1.DataFormats.Float = "g";
    pdfExport1.DataFormats.Integer = "g";
    pdfExport1.DataFormats.Time = "H:mm";
    pdfExport1.FileName = Guid.NewGuid() + ".pdf";
    pdfExport1.PDFOptions.DataFont.CustomFont = new System.Drawing.Font("Arial", 10F);
    pdfExport1.PDFOptions.FooterFont.CustomFont = new System.Drawing.Font("Arial", 10F);
    pdfExport1.PDFOptions.HeaderFont.CustomFont = new System.Drawing.Font("Arial", 10F);
    pdfExport1.PDFOptions.PageOptions.Format = Spire.DataExport.PDF.PageFormat.User;
    pdfExport1.PDFOptions.PageOptions.Height = 11.67;
    pdfExport1.PDFOptions.PageOptions.MarginBottom = 0.78;
    pdfExport1.PDFOptions.PageOptions.MarginLeft = 1.17;
    pdfExport1.PDFOptions.PageOptions.MarginRight = 0.57;
    pdfExport1.PDFOptions.PageOptions.MarginTop = 0.78;
    pdfExport1.PDFOptions.PageOptions.Width = 10.25;
    pdfExport1.PDFOptions.TitleFont.CustomFont = new System.Drawing.Font("Arial", 10F);
    pdfExport1.SQLCommand = command; 
    
    pdfExport1.SaveToFile();
    }
    
    But the Spire.DataExport does not currently support the other 2 requirements 'only printing and 128bit security'.
    Discuss here
    I want to export data to PDF from SQL. will free Spire.DataExport help me to do this?
    A : You can export data from database to PDF by using SQL command. You can refer to our demo here: Data Export PDF for C#, VB.NET.
    Discuss here
    I'm using SPIRE EXPORT PDF as I want to generate from a datagridview (VB.NET 2010) a pdf... I'm doing it through a mysql database as I didn't find a way to do it directly!
    So the code below saves the data written in the datagridview to the mysql bdd and then, it does an SQL to PDF with SPIRE export pdf.
    'PrintDocument1.Print()
            Dim oleDbConnection1 = New MySqlConnection()
            
            Dim Server As String = "localhost"
            Dim Db As String = "PINF"
            Dim User As String = "root"
            Dim Pwd As String = ""
    
            oleDbConnection1.ConnectionString = "Server=" & Server & ";" _
            & "Uid=" & User & ";" _
            & "Pwd=" & Pwd & ";" _
            & " Database=" & Db & ";"
            
            Dim oleDbCommand1 As New MySqlCommand
            oleDbCommand1.Connection = oleDbConnection1
            oleDbConnection1.Open()
            For i = 0 To dgv.RowCount - 2
    
            oleDbCommand1.CommandText = "insert into ATL values ('" & dgv(0, i).Value & "', '" & dgv(1, i).Value & "', '" & dgv(2, i).Value & "', '" & dgv(3, i).Value & "', '" & dgv(4, i).Value & "', '" & dgv(5, i).Value & "', '" & dgv(6, i).Value & "')"
            oleDbCommand1.ExecuteScalar()
    
            Next
    
            Dim pdfExport1 As New Spire.DataExport.PDF.PDFExport()
            pdfExport1.PDFOptions.PageOptions.Orientation = 0
            pdfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
            pdfExport1.DataFormats.CultureName = "fr-FR"
            pdfExport1.DataFormats.Currency = "€"
            pdfExport1.DataFormats.DateTime = "d-M-yyyy"
            pdfExport1.DataFormats.Float = "g"
            pdfExport1.DataFormats.[Integer] = "g"
            pdfExport1.DataFormats.Time = "H:mm"
            pdfExport1.PDFOptions.HeaderFont.AllowCustomFont = True
            pdfExport1.PDFOptions.DataFont.AllowCustomFont = True
            pdfExport1.PDFOptions.FooterFont.AllowCustomFont = True
            pdfExport1.PDFOptions.TitleFont.AllowCustomFont = True
            pdfExport1.AutoFitColWidth = False
            pdfExport1.FileName = "sample1.pdf"
            pdfExport1.PDFOptions.DataFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
            pdfExport1.PDFOptions.FooterFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
            pdfExport1.PDFOptions.HeaderFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
            pdfExport1.PDFOptions.PageOptions.Format = Spire.DataExport.PDF.PageFormat.User
            pdfExport1.PDFOptions.PageOptions.Height = 11.67
            pdfExport1.PDFOptions.PageOptions.MarginBottom = 0.78
            pdfExport1.PDFOptions.PageOptions.MarginLeft = 1.17
            pdfExport1.PDFOptions.PageOptions.MarginRight = 0.57
            pdfExport1.PDFOptions.PageOptions.MarginTop = 0.78
            pdfExport1.PDFOptions.PageOptions.Width = 20 
            pdfExport1.PDFOptions.TitleFont.CustomFont = New System.Drawing.Font("Arial", 10.0F)
    
            pdfExport1.PDFOptions.ColSpacing = 0
            pdfExport1.PDFOptions.RowSpacing = 2
            pdfExport1.PDFOptions.GridLineWidth = 2
            oleDbCommand1.CommandText = "select * from ATL"
            pdfExport1.Header.Text = "ATL"
    
            'pdfExport1.PDFOptions.TitleFont.CustomFont = New System.Drawing.Font("Arial", 20.0F, FontStyle.Bold)
            pdfExport1.SQLCommand = oleDbCommand1
    
            pdfExport1.SaveToFile()
            oleDbConnection1.Close()
    
    But in the resulted PDF file... the display is bad, I mean there are not all columns displayed... and the columns are too spaced ! I don't know how to reduce the spacing of the columns... if someone knows...
    A : Sorry, dataexport does not support custom column header at present. You could use Spire.Doc, by which you can export you data to a document and convert it to pdf please check here to get more information about Spire.Doc.
    Discuss here
    Is it possible to export data from database to Word with images and hyperlinks inserted with the free data export library?
    A : The free library can support several styles of Excel. Therefore, you can insert images and hyperlinks when exporting data to Word by using it. Check it here.
    Discuss here
    I want to use Spire.DataExport to control the data source with SQL command. How can I realize it?
    A : You can use the code:
    System.Data.OleDb.OleDbCommand oleDbcommand1 = new System.Data.OleDb.OleDbCommand(); 
    
    And write SQL command in oleDbcommand1.
    Discuss here
    I want to generate a chart according to my data after exporting data to Excel? Does the free Spire.DataExport support this?
    A : Yes, our free library supports it. Please check it on: Data Export Bar Chart for C#, VB.NET. Download Data Export library here.
    I learn that you can provide free data export library for downloading. I want to know if this library can export a large amount of data, for example, nearly 16000 columns.
    A : There is no column limitation of the free library. But, it will be limited by the file size. What's more, it supports only 65536 columns of Excel 2003.
    Discuss here
    Yesterday, I used Spire.DataExport to export data from database, but I can't connect my database.
    Here I give you my code:
    OleDbConnection oleDbConnection = new OleDbConnection(); 
    oleDbConnection.ConnectionString = this.txtCollectionString.Text;
    System.Data.OleDb.OleDbCommand oleDbCommand = new System.Data.OleDb.OleDbCommand();
    oleDbCommand.CommandText = this.txtCommandText.Text; 
    
    Can you help me? Thank you in advance.
    A : I have realized your problem. After initializing the oleDbConnection and oleDbCommand, you should connect them with the following code:
    oleDbCommand.Connection = oleDbConnection;
    
    Discuss here
    When I fill my data table with the data source of the DataGridView, it appears an error.
    I give you the code:
    worksheet1.DataTable = this.dataGridView.DataSource;
    
    A : You don't convert the type. You should use the following code:
    worksheet1.DataTable = this.dataGridView.DataSource as DataTable;
    
    Discuss here
    I want to assign the data source of the DataGridView with the oleDbCommand, but I failed.
    The code:
    dataGridView.DataSource = oleDbCommand;
    
    A : If you want to do so, you should use a data adapter, it like a intermediary of the command and DataGridView. You may use it with the following code:
    OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand); 
    DataTable dt = new DataTable();
    da.Fill(dt);
    dataGridView.DataSource = dt;
    
    Discuss here
    When I use Spire.DataExport to export data from a database to a worksheet of XLS, it appears an error. I don't know why.
    Here is my code:
    Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet(); 
    worksheet1.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
    worksheet1.DataTable = this.dataGridView.DataSource as DataTable;
    
    A : When I use Spire.DataExport to export data from a database to a worksheet of XLS, it appears an error. I don't know why. Here is my code:
    Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet(); 
    worksheet1.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
    worksheet1.DataTable = this.dataGridView.DataSource as DataTable;
    
    Discuss here
    When I run my form, it will save to a file, but it can't open automatically. So I want it launched automatically. Can you help me?
    A : Of cource. You can use the following code to realize it:
    cellExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
    
    Discuss here
    I am using the DataExport and trying to build an XLS (Excel) with multiple workbooks/sheets (some people may call it tabs). I followed the following example from e-iceblue's own website.
    The example works great, if you are going to add a maximum of 3 workbooks. I am in need of having around 6. If I try to add a fourth workbook, I do not get an error but I also don't get the fourth workbook. I was thinking I might have an error in the fourth workbook, so I comment out the 3rd workbook's code and then I ran it again, the 4th workbook can now be seen (In workbook location #3)! Wow, so the fourth workbook has no errors! I uncommited the code for the 3rd workbook and bammm, the fourth workbook can't be seen again. Only the first 3 workbooks can be seen.
    There must be some sort of limitations on how many workbooks can be added?
    A : Sorry for any inconvenience caused by us. It looks like that your program worked on Spire.DataExport Community Edition. The maximum of 3 worksheets is a limitation. We also provide a Charged Edition of Spire.DataExport which can support up to 256 worksheets. You could get more information about the difference between them from the last table here. You could buy a license of Spire.DataExport Charged Edition from here.
    Discuss here
    When i try to save a export specification to file, it throws an exception "ArgumentOutOfRangeException".
    My code:
    Dim txtExport1 As New Spire.DataExport.TXT.TXTExport()
    
    txtExport1.DataSource = Spire.DataExport.Common.ExportSource.DataTable
    txtExport1.DataEncoding = Spire.DataExport.Common.EncodingType.ASCII
    txtExport1.ExportType = Spire.DataExport.TXT.TextExportType.CSV
    
    txtExport1.SaveSpecificationToFile("C:\test.txt")
    
    A : You can use this method.
    txtExport1.SaveToFile("C:\test.txt");
    
    The SaveSpecificationToFile() method can not work.

    Discuss here
    I opened the export file and excel show popup "Excel found unreadable content in 'xxxxxxx.xls'. Do you want to recover..." Why that popup show and how to hide it ?
    A : We need your code and files. Please upload to us, so that we can reproduce the problem.
    Discuss here