Live Demo (22)
- Demo
- Java
- C# source
This demo shows you how to create chart in an excel workbook.
import com.spire.xls.*; public class ChartDemo { public void chartDemo(String excelFile, ExcelChartType chartType, String resultFileName){ Workbook workbook = new Workbook(); workbook.loadFromFile(excelFile); Worksheet worksheet = workbook.getWorksheets().get(0); setChart(worksheet,chartType); sheetStyle(workbook,worksheet); workbook.saveToFile(resultFileName+".xlsx",FileFormat.Version2013); } private void setChart(Worksheet sheet, ExcelChartType chartType){ sheet.setName("Chart data"); sheet.setGridLinesVisible(false); //Add a new chart worsheet to workbook Chart chart = sheet.getCharts().add(); chart.setChartType(chartType); //Set region of chart data chart.setDataRange(sheet.getCellRange("A1:C7")); chart.setSeriesDataFromRange(false); //Set position of chart chart.setLeftColumn(4); chart.setTopRow(2); chart.setRightColumn(12); chart.setBottomRow(22); //Chart title chart.setChartTitle("Sales market by country"); chart.getChartTitleArea().isBold(true); chart.getChartTitleArea().setSize(12); chart.getPrimarySerieAxis().setTitle("Country"); chart.getPrimarySerieAxis().getFont().isBold(true); chart.getPrimarySerieAxis().getTitleArea().isBold(true); chart.getPrimarySerieAxis().setTitle("Sales(in Dollars)"); chart.getPrimarySerieAxis().hasMajorGridLines(false); chart.getPrimarySerieAxis().getTitleArea().setTextRotationAngle(90); chart.getPrimarySerieAxis().setMinValue(1000); chart.getPrimarySerieAxis().getTitleArea().isBold(true); chart.getPlotArea().getFill().setFillType(ShapeFillType.SolidColor); chart.getPlotArea().getFill().setForeKnownColor(ExcelColors.White); for (int i = 0; i < chart.getSeries().getCount(); i++){ chart.getSeries().get(i).getFormat().getOptions().isVaryColor(true); chart.getSeries().get(i).getDataPoints().getDefaultDataPoint().getDataLabels().hasValue(true); } chart.getLegend().setPosition(LegendPositionType.Top); } public static void sheetStyle(Workbook workbook, Worksheet sheet){ CellStyle oddStyle = workbook.getStyles().addStyle("oddStyle"); oddStyle.getBorders().getByBordersLineType(BordersLineType.EdgeLeft).setLineStyle(LineStyleType.Thin); oddStyle.getBorders().getByBordersLineType(BordersLineType.EdgeTop).setLineStyle(LineStyleType.Thin); oddStyle.getBorders().getByBordersLineType(BordersLineType.EdgeBottom).setLineStyle(LineStyleType.Thin); oddStyle.setKnownColor(ExcelColors.LightGreen1); CellStyle evenStyle = workbook.getStyles().addStyle("evenStyle"); evenStyle.getBorders().getByBordersLineType(BordersLineType.EdgeLeft).setLineStyle(LineStyleType.Thin); evenStyle.getBorders().getByBordersLineType(BordersLineType.EdgeRight).setLineStyle(LineStyleType.Thin); evenStyle.getBorders().getByBordersLineType(BordersLineType.EdgeTop).setLineStyle(LineStyleType.Thin); evenStyle.getBorders().getByBordersLineType(BordersLineType.EdgeBottom).setLineStyle(LineStyleType.Thin); evenStyle.setKnownColor(ExcelColors.LightTurquoise); for (int i = 0; i < sheet.getAllocatedRange().getRows().length; i++) { CellRange[] ranges = sheet.getAllocatedRange().getRows(); if (ranges[i].getRow() != 0){ if (ranges[i].getRow() % 2 == 0) { ranges[i].setCellStyleName(evenStyle.getName()); } else { ranges[i].setCellStyleName(oddStyle.getName()); } } } //Sets header style CellStyle styleHeader = workbook.getStyles().addStyle("headerStyle"); styleHeader.getBorders().getByBordersLineType(BordersLineType.EdgeLeft).setLineStyle(LineStyleType.Thin); styleHeader.getBorders().getByBordersLineType(BordersLineType.EdgeRight).setLineStyle(LineStyleType.Thin); styleHeader.getBorders().getByBordersLineType(BordersLineType.EdgeTop).setLineStyle(LineStyleType.Thin); styleHeader.getBorders().getByBordersLineType(BordersLineType.EdgeBottom).setLineStyle(LineStyleType.Thin); styleHeader.setVerticalAlignment(VerticalAlignType.Center); styleHeader.setKnownColor(ExcelColors.Green); styleHeader.getFont().setKnownColor(ExcelColors.White); styleHeader.getFont().isBold(true); styleHeader.setHorizontalAlignment(HorizontalAlignType.Center); for (int i = 0; i < sheet.getRows()[0].getCount(); i++) { CellRange range = sheet.getRows()[0]; range.setCellStyleName(styleHeader.getName()); } sheet.getColumns()[sheet.getAllocatedRange().getLastColumn() -1].getStyle().setNumberFormat("\"$\"#,##0"); sheet.getColumns()[sheet.getAllocatedRange().getLastColumn() -2].getStyle().setNumberFormat("\"$\"#,##0"); sheet.getRows()[0].getStyle().setNumberFormat("General"); sheet.getAllocatedRange().autoFitColumns(); sheet.getAllocatedRange().autoFitRows(); sheet.getRows()[0].setRowHeight(20); } }
No Matter How Big or Small Your Project is,
Any technical question related to our product, contact us at support@e-iceblue.com.
Any question related to the purchase of product, contact us at sales@e-iceblue.com.
If you don't find the function you want, please request a free demo from us.
Published in
Spire.XLS
Upload
Maximum file size: 1 MB. Files accepted: xls, xlsx, xlsb, ods.
Click here to browse files.
fileerrors
Convert to
Source file:
filename
Target file type:
- Demo
- Java
- C# source
This demo shows you how to convert a Excel document (xls/xlsx/xlsb/ods) to PDF, HTML, Image.
import com.spire.xls.FileFormat; import com.spire.xls.Workbook; import com.spire.xls.core.spreadsheet.HTMLOptions; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; public class ConvertDemo { public void convertDemo(String filePath, String convertTo, String resultFileName) throws IOException { Workbook workbook = new Workbook(); workbook.loadFromFile(filePath); ConvertFormat(workbook,convertTo,resultFileName); } private void ConvertFormat(Workbook workbook, String convertTo, String resultFileName) throws IOException { switch (convertTo){ case "PDF": workbook.getConverterSetting().setSheetFitToPage(true); workbook.saveToFile(resultFileName + ".pdf", FileFormat.PDF); break; case "IMAGE": BufferedImage[] images = (BufferedImage[]) new Image[workbook.getWorksheets().size()]; for (int i = 0; i < workbook.getWorksheets().size();i++){ images[i] = workbook.saveAsImage(i,300,300); } if (images != null && images.length > 0){ if (images.length == 1){ ImageIO.write(images[0],".PNG", new File(resultFileName+".png")); } }else { for (int j = 0; j < images.length;j++){ String fileName = String.format("image-{0}.png",j); ImageIO.write(images[j],".PNG",new File(fileName)); } } break; case "HTML": for (int i = 0; i < workbook.getWorksheets().size(); i++) { HTMLOptions options = new HTMLOptions(); options.setImageEmbedded(true); String htmlPath = String.format(resultFileName+"-{0}.html",i++); workbook.getWorksheets().get(i).saveToHtml(htmlPath,options); } break; case "TIFF": workbook.saveToTiff(resultFileName+".tiff"); break; case "XPS": workbook.saveToFile(resultFileName+".xps",FileFormat.XPS); break; } } }
No Matter How Big or Small Your Project is,
Any technical question related to our product, contact us at support@e-iceblue.com.
Any question related to the purchase of product, contact us at sales@e-iceblue.com.
If you don't find the function you want, please request a free demo from us.
Published in
Spire.XLS
Agreement Start Date: | |
Agreement End Date: | |
Agreement Extension Date: | |
Documentation Start Date: | |
Documentation End Date: | |
downloads
|
- Demo
- Java
- C# source
This demo shows you how to merge some data into a Word template. Our Spire.Doc provides also the function NestedMailMerge with which you can merge the main-table and sub-table into a Word template to get a professional report. You can get a full demo from the article How to Use Mail Merge to Create Report
import com.spire.doc.Document; import com.spire.doc.FileFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; public class MailMargeDemo { public void mailMerge(String docFile, String resultFilePath) throws Exception { Document doc = new Document(); doc.loadFromFile(docFile); SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar=Calendar.getInstance(); ArrayList dateList=new ArrayList<>(); int []offset={-5,5,6,-2,2}; for(int data:offset){ calendar.setTime(new Date()); calendar.add(Calendar.YEAR,data); dateList.add(format.format(calendar.getTime())); } String[] values =new String[dateList.size()]; dateList.toArray(values); String []fields={ "SubGrantPAStartDateValue", "SubGrantPAEndDateValue", "SubGrantPAExtensionDateValue", "SubGrantPSStartDateValue", "SubGrantPSEndDateValue" }; doc.getMailMerge().execute(fields,values); doc.saveToFile(resultFilePath, FileFormat.Docx); } }
No Matter How Big or Small Your Project is,
Any technical question related to our product, contact us at support@e-iceblue.com.
Any question related to the purchase of product, contact us at sales@e-iceblue.com.
If you don't find the function you want, please request a free demo from us.
Published in
Spire.Doc Samples
Data
Name | Capital | Continent | Area | Population | Flag |
Argentina | Buenos Aires | South America | 2777815 | 32300003 | |
Bolivia | La Paz | South America | 1098575 | 7300000 | |
Brazil | Brasilia | South America | 8511196 | 150400000 | |
Canada | Ottawa | North America | 9976147 | 26500000 | |
Chile | Santiago | South America | 756943 | 13200000 | |
Colombia | Bagota | South America | 1138907 | 33000000 | |
Cuba | Havana | North America | 114524 | 10600000 | |
Ecuador | Quito | South America | 455502 | 10600000 | |
El Salvador | San Salvador | North America | 20865 | 5300000 | |
Guyana | Georgetown | South America | 214969 | 800000 |
Option
downloads
- Demo
- Java
- C# source
This demo shows you how to create a table with specified data in a Word document. We also show you how to set the border and background color of the table.
No Matter How Big or Small Your Project is,
Any technical question related to our product, contact us at support@e-iceblue.com.
Any question related to the purchase of product, contact us at sales@e-iceblue.com.
If you don't find the function you want, please request a free demo from us.
Published in
Spire.Doc Samples
Published in
Spire.Doc Samples
Upload
Maximum file size: 1 MB. Files accepted: doc, docx, txt, rtf.
Click here to browse files.
fileerrors
Convert to
Source file:
filename
Search Text:
- Demo
- Java
- C# source
This demo shows you how to search text in a Word document and highlight the text matched.
import com.spire.doc.Document; import com.spire.doc.FileFormat; import com.spire.doc.documents.TextSelection; import java.awt.*; public class FindHighlightDemo { public void findHeighlight(String docFile, String findText, String resultFilePath){ Document doc = new Document(); doc.loadFromFile(docFile); TextSelection[] textSelections = doc.findAllString(findText, false, true); if(textSelections!=null){ for (TextSelection selection : textSelections) { selection.getAsOneRange().getCharacterFormat().setHighlightColor(Color.YELLOW); } } doc.saveToFile(resultFilePath, FileFormat.Docx); } }
No Matter How Big or Small Your Project is,
Any technical question related to our product, contact us at support@e-iceblue.com.
Any question related to the purchase of product, contact us at sales@e-iceblue.com.
If you don't find the function you want, please request a free demo from us.
Published in
Spire.Doc Samples
Upload
Maximum file size: 1 MB. Files accepted: doc, docx, txt, rtf.
Click here to browse files.
fileerrors
Convert to
Source file:
filename
Target file type:
- Demo
- Java
- C# source
This demo shows you how to convert a Word document (doc/docx) to PDF, HTML, Image, XPS, RTF and other file format.
No Matter How Big or Small Your Project is,
Any technical question related to our product, contact us at support@e-iceblue.com.
Any question related to the purchase of product, contact us at sales@e-iceblue.com.
If you don't find the function you want, please request a free demo from us.
Published in
Spire.Doc Samples
Welcome to E-iceblue Live Demos!
Live Demo gives you something quite different; taking you through individual pieces of E-iceblue products' functionality. You can use your own documents and get to see the result straight away by alerting the tabs at the top of the page.
If you don't find the function you want, please request a free demo from us. Make sure the demo you want meets the following requirements:
- It is a small project that implements a particular scenario.
- It relates to our libraries stored on E-iceblue online store.
- It costs less than 2 hours for us to complete it.
- It is not a bug report.
- It is not a feature request.
Recently Updated
{latest:5}
Most Viewed
{hot:5}
Published in
Live Demo