Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Plugins/Aspose_Cells_Java_for_PHP/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Aspose.Cells Java for PHP
Aspose Cells Java for PHP is a PHP project that demonstrates / provides the Aspose.Cells for Java API usage examples in PHP by using PHP/JAVA Bridge.

You will need to configure PHP/Java Bridge before using any of the Aspose provided Java APIs in PHP e.g Aspose.Words, Aspose.Cells and Aspose.Slides etc.

For the configuration/setup of PHP/Java Bridge, please see:

http://php-java-bridge.sourceforge.net/pjb/index.php

To download Aspose.Cells for Java API to be used with these examples through PHP/Java Bridge
Please navigate to:

http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/

For most complete documentation of the project, check Aspose.Words Java for PHP confluence wiki link:

http://www.aspose.com/docs/display/cellsjava/5.+Aspose.Cells+Java+for+PHP



21 changes: 21 additions & 0 deletions Plugins/Aspose_Cells_Java_for_PHP/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "asposecells/aspose_cells_java_for_php",
"description": "Aspose Cells Java Examples for PHP Developers. Helps you understand how to use Aspose.Cells Java classes in your PHP Projects.",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Fahad Adeel",
"email": "fahadadeel@gmail.com"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"Aspose\\Cells\\": "src/aspose/cells"
}
}
}
19 changes: 19 additions & 0 deletions Plugins/Aspose_Cells_Java_for_PHP/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php
/**
* Created by PhpStorm.
* User: fahadadeel
* Date: 21/07/15
* Time: 4:14 PM
*/

namespace Aspose\Cells\WorkingWithFiles\FileHandlingFeatures;

use com\aspose\cells\Workbook as Workbook;
use com\aspose\cells\LoadOptions as LoadOptions;
use com\aspose\cells\FileFormatType as FileFormatType;
use java\io\FileInputStream as FileInputStream;



class OpeningFiles {

public static function run($dataDir=null)
{

$fileFormatType = new FileFormatType();

// 1.
// Opening from path.
//Creating an Workbook object with an Excel file path
$workbook1 = new Workbook($dataDir . "Book1.xls");

// Print message

print("<br />");
print ("Workbook opened using path successfully.");

// 2.
// Opening workbook from stream
//Create a Stream object
$fstream = new FileInputStream($dataDir . "Book2.xls");

//Creating an Workbook object with the stream object
$workbook2 = new Workbook($fstream);

$fstream->close();

// Print message
print("<br />");
print ("Workbook opened using stream successfully.");


// 3.
// Opening Microsoft Excel 97 Files
//Createing and EXCEL_97_TO_2003 LoadOptions object
$loadOptions1 = new LoadOptions($fileFormatType->EXCEL_97_TO_2003);

//Creating an Workbook object with excel 97 file path and the loadOptions object
$workbook3 = new Workbook($dataDir . "Book_Excel97_2003.xls", $loadOptions1);

// Print message
print("<br />");
print("Excel 97 Workbook opened successfully.");



// 4.
// Opening Microsoft Excel 2007 XLSX Files
//Createing and XLSX LoadOptions object
$loadOptions2 = new LoadOptions($fileFormatType->XLSX);

//Creating an Workbook object with 2007 xlsx file path and the loadOptions object
$workbook4 = new Workbook($dataDir . "Book_Excel2007.xlsx", $loadOptions2);

// Print message
print("<br />");
print ("Excel 2007 Workbook opened successfully.");



// 5.
// Opening SpreadsheetML Files
//Creating and EXCEL_2003_XML LoadOptions object
$loadOptions3 = new LoadOptions($fileFormatType->EXCEL_2003_XML);

//Creating an Workbook object with SpreadsheetML file path and the loadOptions object
$workbook5 = new Workbook($dataDir . "Book3.xml", $loadOptions3);

// Print message
print("<br />");
print ("SpreadSheetML format workbook has been opened successfully.");

// 6.
// Opening CSV Files
//Creating and CSV LoadOptions object
$loadOptions4 = new LoadOptions($fileFormatType->CSV);

//Creating an Workbook object with CSV file path and the loadOptions object
$workbook6 = new Workbook($dataDir . "Book_CSV.csv", $loadOptions4);

// Print message
print("<br />");
print ("CSV format workbook has been opened successfully.");



// 7.
// Opening Tab Delimited Files
//Creating and TAB_DELIMITED LoadOptions object
$loadOptions5 = new LoadOptions($fileFormatType->TAB_DELIMITED);

//Creating an Workbook object with Tab Delimited text file path and the loadOptions object
$workbook7 = new Workbook($dataDir . "Book1TabDelimited.txt", $loadOptions5);

// Print message
print("<br />");
print ("Tab Delimited workbook has been opened successfully.");



// 8.
// Opening Encrypted Excel Files
//Creating and EXCEL_97_TO_2003 LoadOptions object
$loadOptions6 = new LoadOptions($fileFormatType->EXCEL_97_TO_2003);

//Setting the password for the encrypted Excel file
$loadOptions6->setPassword("1234");

//Creating an Workbook object with file path and the loadOptions object
$workbook8 = new Workbook($dataDir . "encryptedBook.xls", $loadOptions6);

// Print message
print("<br />");
print ("Encrypted workbook has been opened successfully.");


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Created by PhpStorm.
* User: assadmahmood
* Date: 21/07/15
* Time: 5:00 PM
*/

namespace Aspose\Cells\WorkingWithFiles\FileHandlingFeatures;

use com\aspose\cells\Workbook as Workbook;
use com\aspose\cells\FileFormatType as FileFormatType;


class SavingFiles {

public static function run($dataDir=null)
{

$fileFormatType = new FileFormatType();

//Creating an Workbook object with an Excel file path
$workbook = new Workbook($dataDir . "book.xls");

//Save in default (Excel2003) format
$workbook->save($dataDir . "book.default.out.xls");

//Save in Excel2003 format
$workbook->save($dataDir . "book.out.xls",$fileFormatType->EXCEL_97_TO_2003);

//Save in Excel2007 xlsx format
$workbook->save($dataDir . "book.out.xlsx", $fileFormatType->XLSX);

//Save in SpreadsheetML format
$workbook->save($dataDir . "book.out.xml", $fileFormatType->EXCEL_2003_XML);

//Print Message
print("<BR>");
print("Worksheets are saved successfully.");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php


namespace Aspose\Cells\WorkingWithFiles\UtilityFeatures;

use com\aspose\cells\Workbook as Workbook;
use com\aspose\cells\ChartType as ChartType;
use com\aspose\cells\ImageOrPrintOptions as ImageOrPrintOptions;
use com\aspose\cells\ImageFormat as ImageFormat;

use java\awt\Color as Color;
use java\io\FileOutputStream as FileOutputStream;



class ChartToImage {

public static function run($dataDir=null)
{

$chartType = new ChartType();
$color = new Color();
$imageFormat = new ImageFormat();

//Create a new Workbook.
$workbook = new Workbook();

//Get the first worksheet.
$sheet = $workbook->getWorksheets()->get(0);

//Set the name of worksheet
$sheet->setName("Data");

//Get the cells collection in the sheet.
$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
$chartIndex = $sheet->getCharts()->add($chartType->COLUMN, 12, 1, 33, 12);
$chart = $sheet->getCharts()->get($chartIndex);

//Set properties of chart title
$chart->getTitle()->setText("Sales By Region");
$chart->getTitle()->getFont()->setBold(true);
$chart->getTitle()->getFont()->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))
$chartPoints = $chart->getNSeries()->get(0)->getPoints();

$point = $chartPoints->get(0);
$point->getArea()->setForegroundColor(java_values($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
$imgOpts = new ImageOrPrintOptions();
$imgOpts->setImageFormat($imageFormat->getEmf());

$fs = new FileOutputStream($dataDir . "Chart.emf");

//Save the chart image file.
$chart->toImage($fs, $imgOpts);

$fs->close();

// Print message
print("<BR>");
print("Processing performed successfully.");

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Created by PhpStorm.
* User: fahadadeel
* Date: 05/08/15
* Time: 10:35 AM
*/

namespace Aspose\Cells\WorkingWithFiles\UtilityFeatures;

use com\aspose\cells\Workbook as Workbook;
use com\aspose\cells\SaveFormat as SaveFormat;


class ConvertingExcelFilesToHtml {

public static function run($dataDir=null)
{
$saveFormat = new SaveFormat();

$workbook = new Workbook($dataDir . "Book1.xls");

//Save the document in PDF format
$workbook->save($dataDir . "OutBook1.html", $saveFormat->HTML);

// Print message
echo "\n Excel to HTML conversion performed successfully.";
}

}
Loading