Tuesday, 06 November 2012 05:49

Remove Attachments from PDF in C#/VB.NET

Different from Word and Excel, PDF enables people to attach various files in it. For the convenience of both protecting the confidential files and avoiding the PDF too large, PDF also allows developers to remove any attachment. This section will introduce a solution to remove attachments from PDF via a PDF component in C#, VB.NET.

Spire.PDF for .NET, a .NET component with rich capabilities in manipulating PDF, enables you to quickly remove attachments from your PDF document. Now please see below picture and view the whole attachments remove solution after it.

Remove PDF Attachments

In the solution, first you need a decision procedure to see whether this PDF file has any attachment, then, remove attachments. There are two situations here. One is to remove all the attachments. You can call this method: Document.Attachments.Clear(). The other is to remove a certain attachment or attachments. You can remove them either by pointing file name for example filename=="e-iceblue.html " or by the file extension such as filename.Contains(".html"). Below solution directly find the PDF via file name. Please remember to download Spire.PDF for .NET before performing the project.

[C#]
using Spire.Pdf;
using Spire.Pdf.Attachments;
using System;
using System.Windows.Forms;


namespace RemoveAttachments
{
    class Program
    {
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "PDF document(*.pdf)|*.pdf";
            DialogResult result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                PdfDocument doc = new PdfDocument();
                doc.LoadFromFile(dialog.FileName);
                PdfAttachmentCollection attachments = doc.Attachments;
                PdfAttachment attachment = null;
                if (doc.Attachments.Count > 0)
                {
                    foreach (PdfAttachment oneAttachment in doc.Attachments)
                    {
                        string filename = oneAttachment.FileName;
                        if (filename == "excel.xlsx")
                        {
                            attachment = oneAttachment;
                            break;
                        }
                    }
                }
                if (attachment != null)
                {
                    doc.Attachments.Remove(attachment);
                }
                doc.SaveToFile("test.pdf");
                System.Diagnostics.Process.Start("test.pdf");
            }
        }
    }
}
[VB.NET]
Imports Spire.Pdf
Imports Spire.Pdf.Attachments
Imports System.Windows.Forms


Namespace RemoveAttachments
	Class Program
		Private Sub button1_Click(sender As Object, e As EventArgs)
			Dim dialog As New OpenFileDialog()
			dialog.Filter = "PDF document(*.pdf)|*.pdf"
			Dim result As DialogResult = dialog.ShowDialog()
			If result = DialogResult.OK Then
				Dim doc As New PdfDocument()
				doc.LoadFromFile(dialog.FileName)
				Dim attachments As PdfAttachmentCollection = doc.Attachments
				Dim attachment As PdfAttachment = Nothing
				If doc.Attachments.Count > 0 Then
					For Each oneAttachment As PdfAttachment In doc.Attachments
						Dim filename As String = oneAttachment.FileName
						If filename = "excel.xlsx" Then
							attachment = oneAttachment
							Exit For
						End If
					Next
				End If
				If attachment IsNot Nothing Then
					doc.Attachments.Remove(attachment)
				End If
				doc.SaveToFile("test.pdf")
				System.Diagnostics.Process.Start("test.pdf")
			End If
		End Sub
	End Class
End Namespace

Spire.PDF is a .NET PDF component, which enables users to perform a wide range of PDF processing tasks directly, such as generate, read, write and modify PDF document in WPF, .NET and Silverlight.

Tuesday, 30 October 2012 02:03

Payment Details

Payment method we accept

We accept all the online payments supported by Paypal or 2Checkout. And we also accept the other payments. Such as Bank/Wire transfer, PO, Check/Money Order etc.

Online Payment Process

Paypal

  • Choose your item and click the button "BUY."
  • Enter the coupon code if you have.
  • In the "Please select Payment Method", Choose Paypal.
  • Proceed the payment by using Paypal.

2Checkout

  • Choose your item and click the button "BUY."
  • In the "Please select Payment Method", Choose 2Checkout.
  • Proceed the payment by using 2Checkout.
  • Enter the coupon code if you have.

Purchase Order payment Process

  • Customer sends inquiry and insists to purchase via Purchase Order
  • We send the product quotation sheet
  • Customer confirms and send purchase order sheet
  • We confirm and sends customer Bank information
  • Customer Pay via Bank Transfer
  • We check payment and send license file once we confirm the payment
  • We Send Invoice to customer

Purchase Security

It is 100% secure to do business with us. The Payment platform we utilize is Paypal and 2Checkout. They are the most trusted global online payment system in the world. The order of your private information, such as credit card number, addresses and so on will never be disclosed without your specific permission. Over the years, there have not been one single complaint so far against the account security.

How and When will the ordered software be sent out

Once you complete the online order, our support team will send the license file to your registered email address via email directly; usually it is less than 18 hours.

Regular file we provide

We provide the regular file including quotation sheet, sales contract and invoice to our customers. Please contact our sales team according to your own requirements.

Refund Policy

We hold the 14-day money back guarantee if our products cannot work normally with error or bug. But sometimes the software doesn't work well due to improper operation. We strongly suggest you contact our support team for help first with detailed problem description. In addition, we do not accept gratuitous refund and the purchase with discount.

Tuesday, 30 October 2012 01:33

How to Get Discount

Overview

We always very thank for long-term support from our customers and would like consider more for customer to get our product with a more acceptable price. Therefore, we launch a discount system for offering customers the best value for money.

No Discount After Sale

We are not able to provide discounts once the order finished due to the cost involved to refund the partial payment. It is very important to contact our sales team(sales@e-iceblue.com) for coupon code before purchasing our products.

Purchase Quantity

You will get 12% off discount automatically to buy at least 3 same licenses (no license type limit) of any products in our store.

Competitive Discount

We offer 30% discount for customers who would like to switch to use E-iceblue products from other component vendors. Also, we are very appreciated if you share your views or opinions to help us improve our products.
For getting the competitive discount, you need to follow the following principles.

  • It is not available to or through resellers.
  • Just one time for one address or company.
  • We must verify if you have used the products of our competitors before, so please share with us the invoice or any other document that proves you were/are using a similar product.
  • We will ask for reasons why you would like to use our products rather than your current products.

For applying the competitive discount, you need to send a request to our sales team. Please show the following points in your post:

  • The product you are using right now
  • The reason you would like to have a change
  • The proof you purchase the products from our competitors.

Our staff will send you the coupon code after reviewing and approving your request.

Share your Story with others via Video about using our products

If you have tried our product and found it useful, you are welcomed to make a video by sharing your reviews or steps by using our product. Then send it to sales@e-iceblue.com for us to review it. We will offer you a competitive discount for purchasing our product.

For More Discount

  • Certain Discount-Purchase through reseller in your country
  • 5% to 8% Discount-Write and publish review of our products on your website or professional reviews website
  • 2% to 5% discount-Share our company link on your website or facebook

Discount for Non-Profit Organizations

If you are non-profit, educational organizations or government agency, please send a discount request to our sales team. Please provide all of your organization details in the request, including organization name, local address, website, Email address etc. After checking your request, our staff will send you the coupon code.
If you still have questions, please don’t hesitate to contact our sales team. We will reply you within 1 business day.

Monday, 29 October 2012 01:11

Create Barcode in Word in C#, VB.NET

Barcode is formed by several blanks and black stripes with a specified order. It presents the brief information of one product, including manufacturer, product name, category, price etc. At present, barcode is widely used in commodity circulation. Also, people can create barcode in Word and print.

Spire.Doc for .NET, a stand-alone professional .NET Word component, enables users to create barcode in Word by using C#, VB.NET. So, this guide will show you the method about how to create via Spire.Doc for .NET.

At first, you need to install barcode font on your system. Then, add barcode text through invoking p.AppendText(string) method and then set text format properties for it, such as FontName, FontSize, TextColor etc. After running, we can get result as following screenshot.

Create Word Barcode

Download and install Spire.Doc for .NET and then use the following code to create barcode in Word.

[C#]
using System.Drawing;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

namespace WordBarcode
{
    class BarCode
    {
        static void Main(string[] args)
        {
            //Create Document
            Document document = new Document();
            Paragraph p = document.AddSection().AddParagraph();

            //Add Barcode and Set Format
            TextRange txtRang = p.AppendText("H63TWX11072");
            txtRang.CharacterFormat.FontName = "C39HrP60DlTt";
            txtRang.CharacterFormat.FontSize = 80;
            txtRang.CharacterFormat.TextColor = Color.SeaGreen;

            //Save and Launch
            document.SaveToFile("barcode.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("barcode.docx");
        }
    }
}
[VB.NET]
Imports System.Drawing
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Fields

Namespace WordBarcode
    Friend Class BarCode
        Shared Sub Main(ByVal args() As String)
            'Create Document
            Dim document As New Document()
            Dim p As Paragraph = document.AddSection().AddParagraph()

            'Add Barcode and Set Format
            Dim txtRang As TextRange = p.AppendText("H63TWX11072")
            txtRang.CharacterFormat.FontName = "C39HrP60DlTt"
            txtRang.CharacterFormat.FontSize = 80
            txtRang.CharacterFormat.TextColor = Color.SeaGreen

            'Save and Launch
            document.SaveToFile("barcode.docx", FileFormat.Docx)
            System.Diagnostics.Process.Start("barcode.docx")
        End Sub
    End Class
End Namespace

Spire.Doc is a Microsoft Word component, which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF, .NET and Silverlight.

Thursday, 25 October 2012 02:09

Renew Subscription

Why to Renew the Subscription

The One Year Subscription only guarantees your one year products update and prior technology/sales support. When the subscription expires, any latest products release or hotfix can’t be enjoyed any more.

When to Renew the Subscription

Generally, you can renew your subscription anytime you want. However we usually send an email to the register email address to remind you to renew your subscription before your subscription goes expired. To renew an existed subscription only costs 60% of the current price, while to re-activate an expired subscription costs 75% of the current product price.

How to Renew the Subscription

You just need to log in to our website with the username with which you bought the product , place a new order of the subscription which needs renewal, apply the coupon code and finish the payment.

If you bought the product from our resellers, you can contact them to renew it or purchase a new subscription.

If you have any problems or any changes, please contact our sales department and we will help you.

Monday, 22 October 2012 02:51

Insert Background Image in WPF

Excel Background Image, one kind of page layout setting, is used to beautify files. Actually, with a beautiful background image, the Excel file will be more attractive to readers. Also, different from inserting image in Excel directly, background image will not cover data information. It means that all the data in Excel can be displayed even though background image is inserted.

Spire.XLS for WPF, a professional component to operate Excel files in WPF applications, enables users to insert background image in Excel. This guide will focus on how to realize this function by using C#, VB.NET.

Assign value for BackgroundImage property of PageSetup in Worksheet class to insert background image. Because the type of BackgroundImage is Bitmap, so the assigned value must be bitmap image. The following screenshot shows result after inserting background image.

Insert Excel Background Image

Download and install Spire.XLS for WPF. Then add a button in MainWindow. Double click the button to use the following code to insert background image in Excel.

[C#]
         Bitmap bm = new Bitmap(Image.FromFile(@"E:\Work\Documents\SampleImage\Flower.jpg"));
            sheet.PageSetup.BackgoundImage = bm;
[VB.NET]
         Dim bm As New Bitmap(Image.FromFile("E:\Work\Documents\SampleImage\Flower.jpg"))
        sheet.PageSetup.BackgoundImage = bm

Spire.XLS allows user to operate Excel document directly such as save to stream, save as web response, copy, lock/unlock worksheet, set up workbook properties, etc. As a professional WPF/.NET/Silverlight Excel component, it owns the ability of inserting content into Excel document, formatting cells and converting Excel documents to popular office file formats. Spire.XLS for WPF supports Excel 97-2003, Excel 2007 and Excel 2010.

Monday, 15 October 2012 07:24

Convert RTF to HTML in WPF

This section will show you a detail solution to easily convert RTF to HTML in your WPF application via a .NET Word component. Only two lines of core code in total will be used to realize your RTF to HTML task in this solution.

Spire.Doc for WPF, as a professional MS Word component on WPF, enables you to accomplish RTF to HTML task through following two methods: Document.LoadFromFile(string fileName, FileFormat fileFormat) called to load your RTF file from system and Document. SaveToFile(string ilename, FileFormat fileFormat) is used to save the RTF file as HTML.

Now, you can download Spire.Doc for WPF and then, view the effect of RTF to HTML task as below picture:

RTF to HTML

Sample Code:

[C#]
using Spire.Doc;
using Spire.Doc.Documents;

namespace wpfrtftohtml
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //Load RTF file
            Document document = new Document();
            document.LoadFromFile(@"..\wpfrtftohtml.rtf", FileFormat.Rtf);
            //Convert rtf to html
            document.SaveToFile("rtftohtml.html", FileFormat.Html);
        }
    }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Documents

Namespace wpfrtftohtml
    
    Public Class MainWindow
        Inherits Window
        Public Sub New()
            MyBase.New
            InitializeComponent
        End Sub
        
        Private Sub button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            'Load RTF file
            Dim document As Document = New Document
            document.LoadFromFile("..\wpfrtftohtml.rtf", FileFormat.Rtf)
            'Convert rtf to html
            document.SaveToFile("rtftohtml.html", FileFormat.Html)
        End Sub
    End Class
End Namespace

A CSV (Comma Separated Values) file is a plain text file that contains data separated by commas. It is widely used to import or export data from one application to another. In some cases, you might need to do conversions between CSV and Excel. In this article, you will learn how to implement this function programmatically in C# and VB.NET using Spire.XLS for .NET library.

Install Spire.XLS for .NET

To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.XLS 

Convert Excel to CSV in C# and VB.NET

The following are the steps to convert Excel to CSV:

  • Create an instance of Workbook class.
  • Load an Excel file using Workbook.LoadFromFile() method.
  • Get the desired worksheet by its index using Workbook.Worksheets[index] property.
  • Save the worksheet as CSV using XlsWorksheet.SaveToFile() method. You can choose one of the following overloaded SaveToFile() methods:
    • SaveToFile(string fileName, string separator)
    • SaveToFile(string fileName, string separator, Encoding encoding)
    • SaveToFile(string fileName, string separator, bool retainHiddenData)
  • C#
  • VB.NET
using Spire.Xls;
using System.Text;

namespace ConvertAWorksheetToCsv
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create an instance of Workbook class
            Workbook workbook = new Workbook();
            //Load an Excel file
            workbook.LoadFromFile("Sample.xlsx");

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

            //Save the worksheet as CSV
            sheet.SaveToFile("ExcelToCSV.csv", ",", Encoding.UTF8);
        }
    }
}

C#/VB.NET: Convert Excel to CSV and Vice Versa

Convert CSV to Excel in C# and VB.NET

The following are the steps to convert CSV to Excel:

  • Create an instance of Workbook class.
  • Load a CSV file using Workbook.LoadFromFile(string fileName, string separator, int startRow, int startColumn) method.
  • Get the desired worksheet by its index using Workbook.Worksheets[index] property.
  • Access the used range of the worksheet using Worksheet.AllocatedRange property. Then set CellRange.IgnoreErrorOptions property as IgnoreErrorType.NumberAsText to ignore possible errors while saving the numbers in the range as text.
  • Autofit columns and rows using CellRange.AutoFitColumns() and CellRange.AutoFitRows() methods.
  • Save the CSV to Excel using Workbook.SaveToFile(string fileName, ExcelVersion version) method.
  • C#
  • VB.NET
using Spire.Xls;

namespace ConvertCsvToExcel
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create an instance of Workbook class
            Workbook workbook = new Workbook();

            //Load a CSV file
            workbook.LoadFromFile(@"ExcelToCSV.csv", ",", 1, 1);

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

            //Access the used range in the worksheet
            CellRange usedRange = sheet.AllocatedRange;
            //Ignore errors when saving numbers in the range as text
            usedRange.IgnoreErrorOptions = IgnoreErrorType.NumberAsText;
            //Autofit columns and rows
            usedRange.AutoFitColumns();
            usedRange.AutoFitRows();

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

C#/VB.NET: Convert Excel to CSV and CSV to Excel

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Excel Panes can be frozen in order to keep certain rows or columns visible when scrolling through the worksheet. This is particularly helpful when you have a huge amount of data that you need to deal with. In this article, you will learn how to freeze rows or/and columns in C# and VB.NET using Sprie.XLS for .NET.

Spire.XLS provides the Worksheet.FreezePanes(int rowIndex, int columnIndex) method to freeze all rows and columns above and left of the selected cell which is determined by the rowIndex and the columnIndex.

C#/VB.NET: Freeze Rows and Columns in Excel

The following sections will demonstrate how to:

Install Spire.XLS for .NET

To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.XLS

Freeze the Top Row

To freeze the top row, the selected cell should be the cell (2, 1) – “A2”. The following are the steps to freeze the top row using Spire.XLS for .NET.

  • Create a Workbook object.
  • Load an Excel file using Workbook.LoadFromFile() method.
  • Get a specific worksheet through Workbook.Worksheets[sheetIndex] property.
  • Freeze the top row by passing (2, 1) to the Worksheet.FreezePanes(int rowIndex, int columnIndex) method as the parameter.
  • Save the workbook to another Excel file using Workbook.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Xls;

namespace FreezeTopRow
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook instance
            Workbook workbook = new Workbook();

            //Load an Excel document
            workbook.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.xlsx");

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

            //Freeze the top row
            sheet.FreezePanes(2, 1);

            //Save to another file
            workbook.SaveToFile("FreezeTopRow.xlsx", ExcelVersion.Version2016);
        }
    }
}

C#/VB.NET: Freeze Rows and Columns in Excel

Freeze the First Column

To freeze the first column, the selected cell should be the cell (1, 2) – “B1”. The following are the steps to freeze the first column using Spire.XLS for .NET.

  • Create a Workbook object.
  • Load an Excel file using Workbook.LoadFromFile() method.
  • Get a specific worksheet through Workbook.Worksheets[sheetIndex] property.
  • Freeze the top row by passing (1, 2) to the Worksheet.FreezePanes(int rowIndex, int columnIndex) method as the parameter.
  • Save the workbook to another Excel file using Workbook.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Xls;

namespace FreezeFirstColumn
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook instance
            Workbook workbook = new Workbook();

            //Load an Excel document
            workbook.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.xlsx");

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

            //Freeze the first column
            sheet.FreezePanes(1, 2);

            //Save to another file
            workbook.SaveToFile("FreezeFirstColumn.xlsx", ExcelVersion.Version2016);
        }
    }
}

C#/VB.NET: Freeze Rows and Columns in Excel

Freeze the First Row and the First Column

To freeze the first row and the first column, the selected cell should be the cell (2, 2) – “B2”. The following are the detailed steps.

  • Create a Workbook object.
  • Load an Excel file using Workbook.LoadFromFile() method.
  • Get a specific worksheet through Workbook.Worksheets[sheetIndex] property.
  • Freeze the first row and the first column by passing (2, 2) to the Worksheet.FreezePanes(int rowIndex, int columnIndex) method as the parameter.
  • Save the workbook to another Excel file using Workbook.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Xls;

namespace FreezeFirstRowAndFirstColumn
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook instance
            Workbook workbook = new Workbook();

            //Load an Excel document
            workbook.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.xlsx");

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

            //Freeze the first row and the first column
            sheet.FreezePanes(2, 2);

            //Save to another file
            workbook.SaveToFile("FreezeFirstRowAndFirstColumn.xlsx", ExcelVersion.Version2016);
        }
    }
}

C#/VB.NET: Freeze Rows and Columns in Excel

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Wednesday, 12 October 2022 01:15

C#/VB.NET: Find and Highlight Data in Excel

The Find function in Excel is one of the most commonly used functions for quickly locating specified data, and users can also highlight the data to make it more obvious. In this article, you will learn how to programmatically find and highlight cells with a specific value using Spire.XLS for .NET.

Install Spire.XLS for .NET

To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.XLS

Find and Highlight Data in Excel

The detailed steps are as follows.

  • Create a Workbook instance.
  • Load a sample Excel file using Workbook.LoadFromFile() method.
  • Get a specified worksheet using Workbook.Worksheets[sheetIndex] property.
  • Find all cells with matching text using Worksheet.FindAllString(string stringValue, bool formula, bool formulaValue) method.
  • Set color to highlight the cells using CellRange.Style.Color property.
  • Save the result file using Workbook.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Xls;
using System.Drawing;

namespace FindHighlight
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Workbook instance
            Workbook workbook = new Workbook();

            //Load a sample Excel file
            workbook.LoadFromFile("Test.xlsx");

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

            //Find all cells with the text "Regulator System"
            foreach (CellRange range in sheet.FindAllString("Regulator System", true, true))
            {
                //Set color to highlight the cells
                range.Style.Color = Color.Yellow;
            }

            //Save the result file
            workbook.SaveToFile("FindHighlight.xlsx", ExcelVersion.Version2016);
        }
    }
} 

C#/VB.NET: Find and Highlight Data in Excel

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.