page 164

A ChartSheet represents a chart sheet. It is a worksheet that contains only a chart. This article will demonstrate how to convert a chart sheet to SVG stream by using Spire.XLS.

Firstly, view the sample Excel worksheets with two chart sheets.

How to save Excel chart sheet to SVG in C#

Convert all the chart sheets to SVG stream:

using System.Drawing.Imaging;
using System.IO;
namespace Convert
{
    class Program
    {
        static void Main(string[] args)
        {
            //load the document from file
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Sample.xlsx");

            //call ToSVGStream(Stream stream) method to save each chart sheet to SVG stream 
            for (int i = 0; i < workbook.Chartsheets.Count; i++)
            {
                FileStream fs = new FileStream(string.Format("chartsheet-{0}.svg", i), FileMode.Create);
                workbook.Chartsheets[i].ToSVGStream(fs);
                fs.Flush();
                fs.Close();
            }


        }
    }
}

Effective screenshot of the two chart sheets to SVG.

How to save Excel chart sheet to SVG in C#

using System.Drawing.Imaging;
using System.IO;
namespace Convert
{
    class Program
    {
        static void Main(string[] args)
        {
            //load the document from file
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Sample.xlsx");

            //get the second chartsheet by name
            ChartSheet cs = workbook.GetChartSheetByName("Chart2");

            //save to SVG stream
            FileStream fs = new FileStream(string.Format("chart2.svg"), FileMode.Create);
            cs.ToSVGStream(fs);
            fs.Flush();
            fs.Close();


        }
    }
}

How to save Excel chart sheet to SVG in C#

Alternative text (alt text) can help people with screen readers understand the content of our table. This article is going to demonstrate how to add or get the alternative text of a table in a word document using Spire.Doc.

In Spire.Doc, we can set or get the alternative text of a table using the Table.Title and Table.TableDescription properties. The following example shows how to add alternative text to a table.

Detail steps:

Step 1: Instantiate a Document object and load a word document.

Document doc = new Document();
doc.LoadFromFile("Input.docx");

Step 2: Get the first section.

Section section = doc.Sections[0];

Step 3: Get the first table in the section.

Table table = section.Tables[0] as Table;

Step 4: Add alt text to the table.

//Add title
table.Title = "Table 1";
//Add description
table.TableDescription = "Description Text";

Step 5: Save the document.

doc.SaveToFile("output.docx", FileFormat.Docx2013);

Screenshot:

Add/Get Alternative Text of Table in Word in C#

Full code:

using Spire.Doc;

namespace Add_Alt_Text_To_Word_Table
{
    class Program
    {
        static void Main(string[] args)
        {
            //Instantiate a Document object
            Document doc = new Document();
            //Load a word document
            doc.LoadFromFile("Input.docx");

            //Get the first section
            Section section = doc.Sections[0];

            //Get the first table in the section
            Table table = section.Tables[0] as Table;
 
            //Add alt text

            //Add tile
            table.Title = "Table 1";
            //Add description
            table.TableDescription = "Description Text";

            //Save the document
            doc.SaveToFile("output.docx", FileFormat.Docx2013);            
        }
    }
}

Fill PDF Form Fields in Java

2018-10-22 03:00:44 Written by Koohji

The tutorial shows you how to access the form fields in a PDF document and how to fill each form field with value by using Spire.PDF for Java.

Entire Code:

import com.spire.pdf.FileFormat;
import com.spire.pdf.PdfDocument;
import com.spire.pdf.fields.PdfField;
import com.spire.pdf.widget.*;


public class FillFormField{
    public static void main(String[] args){
    	
        //create a PdfDocument object
        PdfDocument doc = new PdfDocument();
        
        //load a sample PDF containing forms
        doc.loadFromFile("G:\\java-workspace\\Spire.Pdf\\Forms.pdf");

        //get the form fields from the document
        PdfFormWidget form = (PdfFormWidget) doc.getForm();
        
        //get the form widget collection
        PdfFormFieldWidgetCollection formWidgetCollection = form.getFieldsWidget();

        //loop through the widget collection and fill each field with value
        for (int i = 0; i < formWidgetCollection.getCount(); i++) {
        	
            PdfField field = formWidgetCollection.get(i);         
            if (field instanceof PdfTextBoxFieldWidget) {
                PdfTextBoxFieldWidget textBoxField = (PdfTextBoxFieldWidget) field;
                textBoxField.setText("Kaila Smith");
            }         
            if (field instanceof PdfRadioButtonListFieldWidget) {
                PdfRadioButtonListFieldWidget radioButtonListField = (PdfRadioButtonListFieldWidget) field;
                radioButtonListField.setSelectedIndex(1);
            }
            if (field instanceof PdfListBoxWidgetFieldWidget) {
                PdfListBoxWidgetFieldWidget listBox = (PdfListBoxWidgetFieldWidget) field;
                listBox.setSelectedIndex(0);
            }
            if (field instanceof PdfCheckBoxWidgetFieldWidget) {
                PdfCheckBoxWidgetFieldWidget checkBoxField = (PdfCheckBoxWidgetFieldWidget) field;
                switch(checkBoxField.getName()){
                case "checkbox1":
                	checkBoxField.setChecked(true);
                	break;
                case "checkbox2":
                	checkBoxField.setChecked(true);
                	break;
                }
            }
            if (field instanceof PdfComboBoxWidgetFieldWidget) {
                PdfComboBoxWidgetFieldWidget comboBoxField = (PdfComboBoxWidgetFieldWidget) field;
                comboBoxField.setSelectedIndex(1);
            }
        }
        
        //Save the file
        doc.saveToFile("FillFormFields.pdf", FileFormat.PDF);
    }

}

Output:

Fill PDF Form Fields in Java

page 164

Coupon Code Copied!

Christmas Sale

Celebrate the season with exclusive savings

Save 10% Sitewide

Use Code:

View Campaign Details