How to view documents using Visual Studio

View documents in Visual Studio with an amazing tool

Xpath Axes

A very useful trick for automation

Review: Spire.DataExport for .NET

A great tool for exporting data in .NET

How to install Arch Linux, step by step, for VMware Workstation (Part I)

First part of a installation tutorial for this beloved OS

How to setup a local repository in Ubuntu

The steps to have a local repo in Ubuntu

Wednesday, May 18, 2016

How to view documents using Visual Studio


There are numerous scenarios in which you need just to display Word documents with a limited interaction from the user, like when providing a service of access to documents that don't need to be converted to another format to be accessed by the users. In cases like this, you could try the tool Spire.DocViewer for .NET (you can also other reviews I wrote for other E-Icleblue: Spire.PDF, Spire.Presentation, Spire.XLS and Spire.DataExport). This is a tool to manipulate Word documents in .NET, and it allows us to:
  • View Word Documents
  • Easily print Word documents
  • Convert document formats
Now I'll give you a quick review of this tool, based in a simple example, where I'll walk through step by step. So, let's check this E-IceBlue product.

Requirements:

For these two last requirements, you might want to check instructions used for similar tools from E-IceBlue. Please check the instructions to create new projects and add references here and here.

Steps:

1. Add ToolStrip to the form, and inside it, add two buttons one to open a document and the other to close it. Use this button:
Add elements

to add the buttons. You should see something like this when you're done:

Let's say that the first button is to open and the second is to close the document. You can change the default image if you want.

2. Double click Form1.Designer.cs. Here, we'll add the code for a field to display the document. This is not in the toolbox because is a Spire.DocViewer element. Here's the complete code of that file:


Now, you should see this in the designer view of the form:
Form with viewer

3. Next, we have to add code to the Form1.cs file. Basically, what I do here is:
  • Add the code in the button for opening documents
  • Add the code in the button for closing documents
Following, the complete code for Form1.cs:


Save everything. Now, just click Start and you'll see you'r app working:
App Running
Now, let's get it work:
Press the first button at the left. A window will opened and you'll be able to browse a doc file. Select it and it will be displayed in the Doc Viewer area:
Select a file

Loading doc

Open document

To close the document, just click the second button.

Conclusions

As with other E-IceBlue products, my experience was positive, mainly because the easy usage of the product. However, I spent some time coding the Doc View in the design file because there was no element in the toolbox for this. I think it would be great if they automatically add the design element to the toolbox when the installation happens. Other than that, I enjoyed using this product. It's easy enough to learn from the demo coding files, but it would be good to have a little tutorial for the design part. You can get more information about this product in the official webpage: http://www.e-iceblue.com/Introduce/word-viewer-net-introduce.html#.VzjSFWgrKhd

Check my reviews of other E-Icleblue products:
Spire.Presentation
Spire.XLS
Spire.DataExport
Spire.PDF

Tuesday, May 17, 2016

Handling PPT files with Spire.Presentation for .NET


Spire.Presentation is a powerful tool to handle PowerPoint files in an easy way. The main features of this tool are:
  • Conversion of presentation slides to different formats
  • All the operations to handle presentation files: Create, open and edit PPT files
One of the first usages of this tool that came to my mind was to use it to convert a presentation of multiple slides into a collection of images. This is something that would be useful to store data and share parts of the presentation. So, I'll use it as an example in this review.

Requirements:
  • Visual Studio 2015 Community Edition (you can download it from here)
  • Any PowerPoint presentation. In my case, I placed a presentation called "Leonardo-da-Vinci.pptx" at C:\testools.
  • Spire.Presentation installed (download it from here)
  • A new Windows Forms project called "TestoolsPresentation"
  • Testools presentation
  • The Spire.DocViewer.Forms.dll  reference added to the project.
  • Spire presentation dll
  • Spire presentation reference added
If you want to see a more detailed explanation about adding the references, check the related articles here and here.

Steps:

1. Add a simple button to the form. If you want, you can change the text property so it looks nicer :)
Form with button
2. Double click the button to go to the code. The Form1.cs file will be opened. The complete code that should be in that file is:

Note: Be careful to specify the full path to the file you want to convert at:

presentation.LoadFromFile(@"C:\testools\Leonardo-da-Vinci.pptx");

Also, you must specify the path and name pattern for the resulting images at:

String fileName = String.Format(@"C:\testools\result-img-{0}.png", i);
image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);

Click Start. You should see your app running:
App running
If you click the button in the app, you should see a set of images in the desired folder:


Spire.Presentation is a great and powerful tool when it comes to handle PowerPoint files in .NET applications. Also, it's easy enough to be understood even by beginners. Another point to take into account is the great amount of documentation available for the tool. There are any tutorials available to the public, so I encourage you to take a look and explore the tool by yourself. You can find the information I mentioned at: http://www.e-iceblue.com/Introduce/presentation-for-net-introduce.html#.VzpJEWgrKhc

Check my reviews of other E-Icleblue products:
Spire.PDF
Spire.XLS
Spire.DataExport
Spire.DocViewer

Tuesday, May 3, 2016

Manage Excel files programmatically with Spire.XLS


The Excel files are already an important and traditional part of the office work practically everywhere in the business world. So, the ability of handling this type of files from the code can be critical, depending on the project you are working on.

Spire.XLS is a tool that allows us to work with Excel files from the code. Some of its features are:
  • It allows to create and edit Excel files
  • Supports conversion from and to Excel
  • Supports both for the old Excel 97-2003 format (.xls) and for the new Excel 2007, Excel 2010 and Excel 2013 (.xlsx, .xlsb, .xlsm), along with Open Office(.ods) format.
  • Several formatting options.
I'm going to test some of those features using a simple example of the usage of the tool.

Prerequisites:
Hands on:

Create a Windows Application form

1. Go to File > New > Project...
2. Select Windows Forms Application and give a name to your project.
New test application
3. Add a button to the form. Since this is a review, we'll keep things simple.



Add the Spire.XLS reference

1. Go to Project > Add Reference..
2. Cick Browse and select the Spire.XLS.dll file. If you are using the default path, it should be at: C:\Program Files (x86)\e-iceblue\Spire.xls\Bin
3. Select Spire.XLS.dll and click OK.


Add the code for handing Excel files

1. Double click the button you added to the form
2. Enter the code for the Excel generation in the click method. The entire code should look like this:


Easy enough, right? Now click Start in Visual Studio. Then, when your application is displayed, click "Create Excel file". After that, the Excel file that you just created should be opened. You'll see the Evaluation Warning in Sheet 4:
Evaluation Warning

Now, open Sheet 1 to see the data we entered in the code:
Application output

Let's export that data into HTML. To do that, follow these steps:

Add a new button to the form:
Second button
Double click the second button and add this code to the second button click method:


Now, click Start in Visual Studio and then click "Export Excel to HTML". A browser window will be opened and you'll see the content of the Excel file in HTML:


As with the rest of the Office related products, Spire.XLS offers a simple but powerful approach to handle Excel files programmatically. One of the things I liked most about the product is the documentation: Plenty and easy to read. It could be said that any user with basic programming experience should be able to use Spire.XLS without any problem. You can check more information about Spire.XLS here.

Check my reviews of other E-Icleblue products:
Spire.Presentation
Spire.DocumentViewer
Spire.DataExport
Spire.PDF