Tuesday, February 25, 2014

How to Convert Charts in Excel Files to Image Files inside Java Apps

This technical tip show how developers can Convert Chart to Image using Aspose.Cells component.  Charts are visually appealing and make it easy for users to see comparisons, patterns, and trends in data. For instance, rather than analyzing columns of worksheet numbers, a chart shows at a glance whether sales are falling or rising, or how actual sales compare to projected sales. People are frequently asked to present statistical and graphical information in an easy to understand and an easy to maintain manner. A picture helps. Sometimes, charts are needed in an application or web pages. Or it might be needed needed for a Word document, a PDF file, a PowerPoint presentation or some other application. In each case, you want to render the chart as an image so that you can use it elsewhere. Aspose.Cells for Java has supported converting charts in Excel files to image files since release 2.1.2.

The following example shows how to convert a chart to render an image file.

[Java Code]
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);
//Set the name of worksheet
sheet.setName("Data");
//Get the cells collection in the sheet.
Cells cells = workbook.getWorksheets().get(0).getCells();
//Put some values into a cells of the Data sheet.
cells.get("A1").setValue("Region");
cells.get("A2").setValue("France");
cells.get("A3").setValue("Germany");
cells.get("A4").setValue("England");
cells.get("A5").setValue("Sweden");
cells.get("A6").setValue("Italy");
cells.get("A7").setValue("Spain");
cells.get("A8").setValue("Portugal");
cells.get("B1").setValue("Sale");
cells.get("B2").setValue(70000);
cells.get("B3").setValue(55000);
cells.get("B4").setValue(30000);
cells.get("B5").setValue(40000);
cells.get("B6").setValue(35000);
cells.get("B7").setValue(32000);
cells.get("B8").setValue(10000);
//Create chart
int chartIndex = sheet.getCharts().add(ChartType.COLUMN, 12, 1, 33, 12);
Chart chart = sheet.getCharts().get(chartIndex);
//Set properties of chart title
chart.getTitle().setText("Sales By Region");
chart.getTitle().getTextFont().setBold(true);
chart.getTitle().getTextFont().setSize(12);
//Set properties of nseries
chart.getNSeries().add("Data!B2:B8", true);
chart.getNSeries().setCategoryData("Data!A2:A8");
//Set the fill colors for the series's data points (France - Portugal(7 points))
ChartPointCollection chartPoints = chart.getNSeries().get(0).getPoints();
ChartPoint point = chartPoints.get(0);
point.getArea().setForegroundColor(Color.getCyan());
point = chartPoints.get(1);
point.getArea().setForegroundColor(Color.getBlue());
point = chartPoints.get(2);
point.getArea().setForegroundColor(Color.getYellow());
point = chartPoints.get(3);
point.getArea().setForegroundColor(Color.getRed());
point = chartPoints.get(4);
point.getArea().setForegroundColor(Color.getBlack());
point = chartPoints.get(5);
point.getArea().setForegroundColor(Color.getGreen());
point = chartPoints.get(6);
point.getArea().setForegroundColor(Color.getMaroon());
//Set the legend invisible
chart.setShowLegend(false);
//Get the Chart image
ImageOrPrintOptions imgOpts = new ImageOrPrintOptions();
imgOpts.setImageFormat(ImageFormat.getPng());
//Save the chart image file.
chart.toImage(new FileOutputStream("D:\\Files\\MyChartImage.png"), imgOpts);

More about Aspose.Cells for Java

Sunday, February 9, 2014

Read Email Messages from Semi-Corrupt PST File & Outlook Message Loading from TNEF

We are pleased to announce the new release of Aspose.Email for Java 3.8.0. This month’s release includes an important enhancement related to reading messages from a semi-corrupt PST file. This makes it possible to read the non-corrupted messages from the PST file which was not possible earlier and provides more stability to PST reading operations. This month’s release also enhances Aspose.Email’s TNEF messages reading capability by filling the named properties collection from TNEF.  This improves the overall Outlook message loading functionality from TNEF in cases where calendar items are encapsulated within a TNEF. In addition to the enhancements, this month’s release also includes a number of bug fixes that affected certain API functionality. These include issues related to messages encoding and conversions, message rendering to MHT and TIFF, start and end times for calendar items, and some exceptions. The main improved features & bug fixes added in this release are listed below
  • Inline images now properly read by MailMessage
  • Exception resolved while converting EML loaded in MailMessage to MapiMessage
  • Exception resolved: 'x-gbk' is now a supported encoding name
  • Email message headers rendered to output MHT
  • Accents converted to special characters, while converting from EML to MSG
  • Wrong start and end time read for MapiCalendar
  • MailMessage identifies HTML message body as Plain Text
  • Provide filling NamedProperies collection when MapiMessage loading from Tnef.
  • EML to MHTML: Korean characters in subject replaced "?"
  • EML to MSG raises System.FormatException
  • MapiMessage.BodyHtml gives ArgumentException
  • MSG Files using Aspose.Email can't be sent from Outlook
Other most recent bug fixes are also included in this release.

Overview:Aspose.Email for Java 

Aspose.Email for Java is a Non-Graphical Java component that enables Java applications to read and write Microsoft Outlook documents without utilizing Microsoft Outlook. It enables developers to create new MSG file from scratch, update an existing MSG file, read Outlook MSG file & get it's properties like subject, body, recipients in to, cc and bcc, Adding or removing attachment, sender information and MAPI properties.  Aspose.Email for Java can be used with Web as well asDesktop Application.