Import Data from JSON to Excel Worksheet in C# .NET

Convert JSON to Excel C#

MS Excel provides a variety of features to keep and organize tabular data in the form of worksheets. Along with data organization, you can perform various operations such as data sorting, graph plotting, mathematical computations and etc. JSON, on the other hand, is a widely used format to store and transmit the data in the form of key-value pairs. Most often, it is used to transmit data from the server to the web pages. There could be the case when you receive the data in the form of JSON, i.e. from a web service, and want to save it into an Excel worksheet. In such a case, the optimal way is automating the process by importing data from JSON to Excel worksheets programmatically.

In order to deal with the above-mentioned scenario in ASP.NET or any C# based application, I’ll show you how to import JSON data into Excel file. In this article, you will learn how to:

  • import data from JSON to Excel worksheet in C#
  • apply cell formatting when converting JSON to Excel in C#

In order to import data from JSON files, we’ll leverage the capabilities of Aspose.Cells for .NET. It is a powerful API to manipulate spreadsheet files in .NET, .NET Core & Xamarin based applications. You can install the API’s package from NuGet or download the DLL directly from the Downloads section.

Import Data from JSON to Excel in C#

The following are the steps to import data from JSON to Excel XLSX:

The following code sample shows how to import data from JSON to Excel in C#.

Input JSON Data

[
   {
       Name: "John Smith",
       Contract:
       [
           {
               Client:
               {
                   Name: "A Company"
               },
               Price: 1200000
           },
           {
               Client:
               {
                   Name: "B Ltd."
               },
               Price: 750000
           },
           {
               Client:
               {
                   Name: "C & D"
               },
               Price: 350000
           }
       ]
   },
   {
       Name: "Tony Anderson",
       Contract:
       [
           {
               Client:
               {
                   Name: "E Corp."
               },
               Price: 650000
           },
           {
               Client:
               {
                   Name: "F & Partners"
               },
               Price: 550000
           }
       ]
   },
   {
       Name: "Jimmy Adams",
       Contract:
       [
           {
               Client:
               {
                   Name: "MIT"
               },
               Price: 800000
           },
           {
               Client:
               {
                   Name: "SnB"
               },
               Price: 520000
           }
       ]
   },
]

Output Excel Worksheet

JSON to Excel

Import JSON to Excel with Formatting Styles in C#

You can also apply different styles to the Excel worksheet when importing the data from JSON file. The CellsFactory class of Aspose.Cells for .NET provides a range of options to set various styling parameters such as font, color, alignment, border styles, etc. The following are the steps to import data from JSON to Excel along with the styling.

The following code sample applies different styles when importing data from JSON to Excel in C#.

Output Excel Worksheet

JSON to Excel C#

See Also

Learn more about Aspose.Cells for .NET

You can explore more about Aspose.Cells for .NET using the documentation and the source code examples.

Posted in Aspose.Cells Product Family | Tagged , , | Leave a comment

C# Convert DICOM to JPEG, GIF, PNG, and BMP Images

DICOM to Image

DICOM (Digital Imaging and Communications in Medicine) is a standard file format for storing medical imaging information. The information stored in the DICOM images is managed in the form of datasets including the header and the image data set. Most often, DICOM images contain medical scans such as ultrasounds, MRIs and etc. which are exchanged between multiple entities to share the patient’s medical information.

In order to view the DICOM images, various offline and online DICOM viewers are available in the market. However, if you want to embed DICOM images in presentations or webpages, you will have to convert them into JPEG, GIF, PNG, BMP or some other image format. In accordance with this scenario, in this article, you will learn how to convert DICOM images programmatically in C#. Ultimately, you will be able to convert DICOM to the following image formats:

  • JPEG
  • GIF
  • PNG
  • BMP

C# DICOM Converter API

In order to convert DICOM images, we’ll use Aspose.Imaging for .NET which is an easy to use API for creating and manipulating various types of images within .NET applications. Aspose.Imaging for .NET is hosted on NuGet as well as available as downloadable binaries.

Convert DICOM to JPEG in C#

The following are the steps to convert DICOM to JPEG in C#:

  • Load the DICOM file into a FileStream object.
  • Create an object of DicomImage class and initialize it with the FileStream object.
  • Select the active page in DICOM that you want to convert to JPEG (if it is not set, the default active page will be converted).
  • Save the converted JPEG image using DicomImage.Save(string, ImageOptionsBase) method.

The following code sample converts a page in DICOM to JPEG in C#.

Input DICOM

DICOM to JPEG

DICOM to JPEG

Convert DICOM to JPEG C#

Convert DICOM to GIF in C#

Converting DICOM to GIF is as simple as pie. Just access the DICOM file and save it with .gif extension. The following are the steps to convert DICOM to animated GIF in C#:

The following code sample shows how to convert DICOM to GIF in C#.

DICOM to GIF

Convert DICOM to GIF C#

Convert DICOM to PNG in C#

Converting DICOM to PNG is as same as converting DICOM to JPEG. Simply access the DICOM file using DicomImage class and save it with .png extension. The following code sample shows how to convert a DICOM to PNG in C#.

Convert DICOM to BMP in C#

In order to convert DICOM to BMP, you can repeat the same steps to access the DICOM file using the DicomImage class. Once done, use DicomImage.Save(string, ImageBaseOptions) method to save DICOM as BMP. The following code sample shows how to convert DICOM to BMP in C#.

Learn more about Aspose.Imaging for .NET

Explore more about working with images using Aspose.Imaging for .NET API.

See also

Posted in Aspose.Imaging Product Family | Tagged , , , , | Leave a comment

AcroForms vs XFA Forms – Convert XFA to AcroForms in PDF

Convert XFA to AcroForms

AcroForms vs XFA Forms

AcroForms are the fillable forms that are used to integrate the form fields in PDF documents. It was the initial forms technology adopted by Adobe for the PDF documents starting from PDF 1.2 specification. AcroForms allow adding the form fields as an overlay to collect the data from the end-users or anyone using the document.

Later, Adobe adopted the XML-based XFA forms (XML Forms Architecture) as part of the PDF 1.5 specification after acquiring Accelio (a service provider). XFA used the capabilities of the XML for developing the e-forms in PDF documents. However, despite being a newer e-form technology as compared to AcroForms, XFA has a few limitations which include:

  • lack of JavaScript support with various PDF objects,
  • XFA forms can be created with Adobe LiveCycle Forms Designer only,
  • compatibility issues with the AcroForms,
  • lack of an automatic conversion from AcroForms to XFA,
  • limited accessibility as compared to AcroForms,
  • requires developer skills to build the forms,
  • and etc.

Since AcroForms technology is considered to be more accessible and easy to use, the upcoming section shows how to perform XFA to AcroForms conversion in PDF programmatically using C# and Java.

Convert XFA to AcroForms

Various XFA to AcroForms conversion tools are available that will let you perform the conversion. However, in order to integrate this feature within your .NET or Java application for automated conversion, you can use Aspose.PDF.

Convert XFA to AcroForms in C#

The following are the steps to convert XFA forms to AcroForm using Aspose.PDF for .NET.

The following code sample converts XFA forms in PDF to AcroForms using C#.

Convert XFA to AcroForms in Java

The following are the steps for XFA to AcroForms conversion using Aspose.PDF for Java.

The following code sample shows how to convert XFA to AcroForms using Java.

Learn more about Aspose.PDF

You can learn more about the Aspose.PDF API using the documentation. In case you would have any questions or queries, contact us via our forum.

See Also

Posted in Aspose.PDF Product Family | Tagged , , , , | Leave a comment

Convert PSD to PDF, JPG, PNG and Other Raster Image Formats in C#

PSD to Image C# 2

The Photoshop Document (PSD) is a well-known file format used by Adobe Photoshop for saving the data in the form of layers. The layers are combined together to obtain the desired artwork or images. Adobe Photoshop allows the designers to export the PSD layers as a single image in the form of PNG, JPG, GIF, TIFF, and other formats.

In case you want to implement the feature of converting or exporting the PSD files to raster image formats without Photoshop, you will definitely look for some automation. For such a case, I am going to demonstrate how to convert PSD to PDF, JPG, PNG, BMP or other raster image formats programmatically using C#. Furthermore, you’ll also learn how to convert or export the desired layer/layer group in the PSD. This article covers the following PSD conversions in C#:

  • PSD to JPG
  • PSD to PNG
  • PSD to BMP
  • PSD to TIFF
  • PSD to GIF
  • PSD to JP2
  • PSD to PDF
  • PSD layer/layer group to image

C# PSD Converter API – Aspose.PSD for .NET

For converting PSD to PDF and image formats, we’ll leverage the capabilities of Aspose.PSD for .NET which is simple and easy to use .NET API for manipulation and conversion of Photoshop files (PSD). In addition to conversion features, the API also lets you create and edit the Photoshop PSD files, update layer properties, insert watermarks, and perform various graphics-related operations on PSD files. Aspose.PSD for .NET can be installed from NuGet as well as downloaded as DLL from the Downloads section.

Convert PSD to JPG in C#

The following are the steps to convert a PSD file to JPG image in C#:

The following code sample shows how to convert a PSD file to JPG in C#:

PSD File

PSD to JPG

Converted JPG Image

PSD to PNG

Convert PSD to PNG in C#

The following are the steps to convert a PSD file to PNG image in C#:

The following code sample shows how to convert a PSD file to PNG in C#:

Convert PSD to BMP in C#

The following are the steps to convert a PSD file to BMP image in C#:

The following code sample shows how to convert a PSD file to BMP in C#:

Convert PSD to TIFF in C#

The following are the steps to convert a PSD file to TIFF image in C#:

The following code sample shows how to convert a PSD file to TIFF in C#:

Convert PSD to GIF in C#

The following are the steps to convert a PSD file to GIF image in C#:

The following code sample converts a PSD file to GIF in C#:

Convert PSD to JP2 in C#

The following are the steps to convert a PSD file to JP2 image in C#:

The following code sample converts a PSD file to JP2 in C#:

Convert PSD to PDF in C#

The following are the steps to convert a PSD file to PDF document in C#:

The following code sample converts a PSD file to PDF document in C#:

Convert a Layer or Layer Group of PSD in C#

You can also convert a particular layer or layer group in the PSD file to raster image formats (JPG, PNG, etc.). The following are the steps to perform this operation.

  • Create an object of the PsdImage class and load the PSD file.
  • Access the layer or layer group using PsdImage.Layers array.
  • Render the layer as an image.

The following code sample shows how to convert a layer group of PSD to PNG in C#.

Learn more about Aspose.PSD for .NET

You can explore more about the Aspose.PSD for .NET using the documentation.

Related Article(s)

Posted in Aspose.PSD Product Family | Tagged , , , , , , , | Leave a comment

Convert PostScript PS/EPS and XPS Documents to PDF and Raster Images in C++

PostScript XPS to PDF and Image C++

In my previous post, I have shown you how easy it is to create or edit PostScript (PS/EPS) and XPS documents programmatically using Aspose.Page for C++. In this article, I’ll demonstrate how to convert PS/EPS or XPS documents to PDF or raster image formats including PNG, JPEG, TIFF, and BMP. The rest of the article is composed of the following sections:

  • Convert a PostScript PS/EPS document to PDF in C++
  • Convert a PostScript PS/EPS document to Image in C++
  • Convert an XPS document to PDF in C++
  • Convert an XPS document to image in C++

Before we start, I assume that you have downloaded Aspose.Page for C++ and referenced it in your C++ project. However, if you haven’t, you can get it installed from NuGet or download the complete package along with a plug and play console application from the Downloads section. 

Convert a PostScript PS/EPS Document to PDF in C++

The following are the steps to convert a PostScript PS/EPS document to PDF:

  • Create a FileStream object for the output PDF file.
  • Load the input PostScript document in a FileStream object.
  • Create and initialize the PsDocument object with the input stream.
  • Create and initialize the PdfDevice object with the output stream.
  • Process the document and save it as a PDF file using the PsDocument->Save method.

The following code sample shows how to convert a PostScript PS document to PDF in C++.

Convert a PostScript PS/EPS Document to Image in C++

The following are the steps to convert PS/EPS to an image format.

  • Create an object of ImageFormat to set the format of the output image, i.e. PNG.
  • Load the input PostScript document in a FileStream object.
  • Create and initialize the PsDocument object with the input stream.
  • Create an object of ImageDevice.
  • Process the document and save it as an image using the PsDocument->Save method.

The following code sample shows how to convert PostScript PS/EPS to image in C++.

Convert an XPS Document to PDF in C++

The following are the steps to convert an XPS document to PDF:

  • Create FileStream objects for input XPS and output PDF files.
  • Load the XPS document stream into an XpsDocument object.
  • Create an object of the PdfDevice class and initialize it with the output stream.
  • Convert the XPS document to PDF using the XpsDocument->Save method.

The following code sample shows how to convert the XPS document to PDF in C++.

Convert an XPS Document to Image in C++

The following are the steps to convert an XPS document to raster image formats:

The following code sample shows how to convert XPS to PNG image in C++.

For converting the XPS document to BMP, TIFF, and JPEG, please visit the following article.

Learn more about Aspose.Page for C++

You can learn more about Aspose.Page for C++ using the documentation and the source code examples.

Posted in Aspose.Page Product Family | Tagged , , , , , | Leave a comment