This article we will demonstrate how to convert the PDF pages to HTML, Word, SVG, XPS, PDF and save them to stream by calling the method PdfDocument.SaveToStream() offered by Spire.PDF. And starts from Spire.PDF version 4.3, it newly supports to convert the defined range of PDF pages and save them to stream.

Save the PDF to stream

Step 1: Create a new PdfDocument instance and load the sample document from file.

PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Sample.pdf");

Step 2: Save the document to stream.

MemoryStream ms=new MemoryStream ();
pdf.SaveToStream(ms);

Save the PDF to stream and defined the file format to HTML, Word, SVG, XPS and PDF

Step 1: Create a new PdfDocument instance and load the sample document from file.

PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Sample.pdf");

Step 2: Save the document to stream and use FileFormat format to define the format.

MemoryStream ms=new MemoryStream ();
pdf.SaveToStream(ms, FileFormat.HTML);

Convert the defined range of PDF pages to HTML, word, SVG, XPS and save them to stream

Step 1: Create a new PdfDocument instance and load the sample document from file.

PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Sample.pdf"); 

Step 2: Only save some PDF pages to stream by using pdf.SaveToStream(int startIndex, int endIndex, FileFormat format) method; and FileFormat.PDF is not supported.

pdf.SaveToStream(1, 2, FileFormat.SVG);

Full codes of save PDF to stream:

using Spire.Pdf;
using System.IO;


namespace SavePDFToStream
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument pdf = new PdfDocument();

            pdf.LoadFromFile("Sample.pdf");

            MemoryStream ms = new MemoryStream();
            pdf.SaveToStream(ms);
            pdf.SaveToStream(ms, FileFormat.HTML);

            pdf.SaveToStream(1, 2, FileFormat.SVG);
        }
    }
}

A legend is displayed in the chart area by default. However it can be removed from the chart. With Spire.XLS, we can delete the whole legend as well as specific legend entries from Excel chart. This article is going to demonstrate how we can use Spire.XLS to accomplish this function.

Below screenshot shows the Excel chart we used for demonstration:

Delete Legend and Specific Legend Entries from Excel Chart in C#

Delete the whole legend

using Spire.Xls;
namespace DeleteLegend
{

    class Program
    {

        static void Main(string[] args)
        {
            //Create a Workbook instance
            Workbook workbook = new Workbook();
            //Load the Excel file
            workbook.LoadFromFile("sample.xlsx");

            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Get the chart
            Chart chart = sheet.Charts[0];

            //Delete legend from the chart
            chart.Legend.Delete();

            //Save the file                        
            workbook.SaveToFile("DeleteLegend.xlsx", ExcelVersion.Version2013);
        }
    }
}

Screenshot:

Delete Legend and Specific Legend Entries from Excel Chart in C#

Delete specific legend entries

using Spire.Xls;
namespace DeleteLegend
{

    class Program
    {

        static void Main(string[] args)
        {
            //Create a Workbook instance
            Workbook workbook = new Workbook();
            //Load the Excel file
            workbook.LoadFromFile("sample.xlsx");

            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            //Get the chart
            Chart chart = sheet.Charts[0];

            //Delete the first and the second legend entries from the chart
            chart.Legend.LegendEntries[0].Delete();
            chart.Legend.LegendEntries[1].Delete();

            //Save the file                        
            workbook.SaveToFile("DeleteLegendEntries.xlsx", ExcelVersion.Version2013);

        }
    }
}

Screenshot:

Delete Legend and Specific Legend Entries from Excel Chart in C#

Multi-level category chart is a chart type that has both main category and subcategory labels. This type of chart is useful when you have figures for items that belong to different categories. In this article, you will learn how to create a multi-level category chart in Excel using Spire.XLS with C# and VB.NET.

Step 1: Create a Workbook instance and get the first worksheet.

Workbook wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];

Step 2: Write data to cells.

sheet.Range["A1"].Text = "Main Category"; 
sheet.Range["A2"].Text = "Fruit";
sheet.Range["A6"].Text = "Vegies";
sheet.Range["B1"].Text = "Sub Category";
sheet.Range["B2"].Text = "Bananas";
sheet.Range["B3"].Text = "Oranges";
sheet.Range["B4"].Text = "Pears";
sheet.Range["B5"].Text = "Grapes";
sheet.Range["B6"].Text = "Carrots";
sheet.Range["B7"].Text = "Potatoes";
sheet.Range["B8"].Text = "Celery";
sheet.Range["B9"].Text = "Onions";
sheet.Range["C1"].Text = "Value";
sheet.Range["C2"].Value = "52";
sheet.Range["C3"].Value = "65";
sheet.Range["C4"].Value = "50";
sheet.Range["C5"].Value = "45";
sheet.Range["C6"].Value = "64";
sheet.Range["C7"].Value = "62";
sheet.Range["C8"].Value = "89";
sheet.Range["C9"].Value = "57";

Step 3: Vertically merge cells from A2 to A5, A6 to A9.

sheet.Range["A2:A5"].Merge();
sheet.Range["A6:A9"].Merge();

Step 4: Add a clustered bar chart to worksheet.

Chart chart = sheet.Charts.Add(ExcelChartType.BarClustered);
chart.ChartTitle = "Value";   
chart.PlotArea.Fill.FillType = ShapeFillType.NoFill;
chart.Legend.Delete();

Step 5: Set the data source of series data.

chart.DataRange = sheet.Range["C2:C9"];
chart.SeriesDataFromRange = false;

Step 6: Set the data source of category labels.

ChartSerie serie = chart.Series[0];
serie.CategoryLabels = sheet.Range["A2:B9"];

Step 7: Show multi-level category labels.

chart.PrimaryCategoryAxis.MultiLevelLable = true;

Step 8: Save the file.

wb.SaveToFile("output.xlsx", ExcelVersion.Version2013);

Output:

Create Multi-Level Category Chart in Excel in C#, VB.NET

Full Code:

[C#]
using Spire.Xls;
using Spire.Xls.Charts;
namespace CreateMutilLevelChart
{

    class Program
    {

        static void Main(string[] args)
        {
            Workbook wb = new Workbook();
            Worksheet sheet = wb.Worksheets[0];

            sheet.Range["A1"].Text = "Main Category";
            sheet.Range["A2"].Text = "Fruit";
            sheet.Range["A6"].Text = "Vegies";
            sheet.Range["B1"].Text = "Sub Category";
            sheet.Range["B2"].Text = "Bananas";
            sheet.Range["B3"].Text = "Oranges";
            sheet.Range["B4"].Text = "Pears";
            sheet.Range["B5"].Text = "Grapes";
            sheet.Range["B6"].Text = "Carrots";
            sheet.Range["B7"].Text = "Potatoes";
            sheet.Range["B8"].Text = "Celery";
            sheet.Range["B9"].Text = "Onions";
            sheet.Range["C1"].Text = "Value";
            sheet.Range["C2"].Value = "52";
            sheet.Range["C3"].Value = "65";
            sheet.Range["C4"].Value = "50";
            sheet.Range["C5"].Value = "45";
            sheet.Range["C6"].Value = "64";
            sheet.Range["C7"].Value = "62";
            sheet.Range["C8"].Value = "89";
            sheet.Range["C9"].Value = "57";
            sheet.Range["A2:A5"].Merge();
            sheet.Range["A6:A9"].Merge();
            sheet.AutoFitColumn(1);
            sheet.AutoFitColumn(2);

            Chart chart = sheet.Charts.Add(ExcelChartType.BarClustered);
            chart.ChartTitle = "Value";
            chart.PlotArea.Fill.FillType = ShapeFillType.NoFill;
            chart.Legend.Delete();
            chart.LeftColumn = 5;
            chart.TopRow = 1;
            chart.RightColumn = 14;
            chart.DataRange = sheet.Range["C2:C9"];
            chart.SeriesDataFromRange = false;
            ChartSerie serie = chart.Series[0];
            serie.CategoryLabels = sheet.Range["A2:B9"];
            chart.PrimaryCategoryAxis.MultiLevelLable = true;
            wb.SaveToFile("output.xlsx", ExcelVersion.Version2013);
        }
    }
}
[VB.NET]
Imports Spire.Xls
Imports Spire.Xls.Charts
Namespace CreateMutilLevelChart

	Class Program

		Private Shared Sub Main(args As String())
			Dim wb As New Workbook()
			Dim sheet As Worksheet = wb.Worksheets(0)

			sheet.Range("A1").Text = "Main Category"
			sheet.Range("A2").Text = "Fruit"
			sheet.Range("A6").Text = "Vegies"
			sheet.Range("B1").Text = "Sub Category"
			sheet.Range("B2").Text = "Bananas"
			sheet.Range("B3").Text = "Oranges"
			sheet.Range("B4").Text = "Pears"
			sheet.Range("B5").Text = "Grapes"
			sheet.Range("B6").Text = "Carrots"
			sheet.Range("B7").Text = "Potatoes"
			sheet.Range("B8").Text = "Celery"
			sheet.Range("B9").Text = "Onions"
			sheet.Range("C1").Text = "Value"
			sheet.Range("C2").Value = "52"
			sheet.Range("C3").Value = "65"
			sheet.Range("C4").Value = "50"
			sheet.Range("C5").Value = "45"
			sheet.Range("C6").Value = "64"
			sheet.Range("C7").Value = "62"
			sheet.Range("C8").Value = "89"
			sheet.Range("C9").Value = "57"
			sheet.Range("A2:A5").Merge()
			sheet.Range("A6:A9").Merge()
			sheet.AutoFitColumn(1)
			sheet.AutoFitColumn(2)

			Dim chart As Chart = sheet.Charts.Add(ExcelChartType.BarClustered)
			chart.ChartTitle = "Value"
			chart.PlotArea.Fill.FillType = ShapeFillType.NoFill
			chart.Legend.Delete()
			chart.LeftColumn = 5
			chart.TopRow = 1
			chart.RightColumn = 14
			chart.DataRange = sheet.Range("C2:C9")
			chart.SeriesDataFromRange = False
			Dim serie As ChartSerie = chart.Series(0)
			serie.CategoryLabels = sheet.Range("A2:B9")
			chart.PrimaryCategoryAxis.MultiLevelLable = True
			wb.SaveToFile("output.xlsx", ExcelVersion.Version2013)
		End Sub
	End Class
End Namespace
page 179