ByteScout Data Extraction Suite - PHP - Create spreadsheet with spreadsheet sdk - ByteScout

ByteScout Data Extraction Suite – PHP – Create spreadsheet with spreadsheet sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Data Extraction Suite – PHP – Create spreadsheet with spreadsheet sdk

How to create spreadsheet with spreadsheet sdk in PHP with ByteScout Data Extraction Suite

Learn to code in PHP to create spreadsheet with spreadsheet sdk with this step-by-step tutorial

These sample source codes on this page below are displaying how to create spreadsheet with spreadsheet sdk in PHP. ByteScout Data Extraction Suite is the set that includes 3 SDK products for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK and you can use it to create spreadsheet with spreadsheet sdk with PHP.

This prolific sample source code in PHP for ByteScout Data Extraction Suite contains various functions and other necessary options you should do calling the API to create spreadsheet with spreadsheet sdk. IF you want to implement the functionality, just copy and paste this code for PHP below into your code editor with your app, compile and run your application. Enjoy writing a code with ready-to-use sample PHP codes.

All these programming tutorials along with source code samples and ByteScout free trial version are available for download from our website.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

HelloWorld.php
      
<?php // this PHP script creates XLS file using Spreadsheet SDK and streams it into the browser for user to download /* IMPORTANT: to use COM objects in PHP need to enable it by adding the following line into php.ini: extension=php_com_dotnet.dll If you are usiung EasyPHP DevServer then to edit php.ini just right-click on the tray icon and select "Configuration"->"PHP" */ try { // create spreadsheet object $document = new COM("Bytescout.Spreadsheet.Spreadsheet"); // Add new worksheet $worksheet = $document->Workbook->Worksheets->Add("123HelloWorld"); // get cell value $cell = $worksheet->Cell(0,0); // you can also use worksheet.Cell_2("A1") as well. Cell_2() is because all overloads are accessible via _Index postfix, like .Cell_2(), .Cell_3() etc // set cell value $cell->Value = "Hello, World!"; // generate and get xls document as an array of bytes $XLSDocumentArray = $document->GetAsBytesArrayXLS(); // now set headers to properly tell what kind of content we stream into browser header("Content-Type: vnd.ms-excel"); // set file name to save into header("Content-Disposition: attachment; filename=\"HelloWorld.xls\""); // now write the array with content into the output foreach ($XLSDocumentArray as $byte) echo chr($byte); } catch(Exception $err) // catch exception if any { header("Content-Type: text/plain"); // switch to plain text output type echo($err->getMessage()); // write error message to the output } ?>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

HowToUseViaDOTNETclass.txt
      
You may use the SDK from PHP on Windows using DOTNET() class in PHP 1) Install the DLL into the GAC (global assembly cache) a) Open "c:\Windows\assembly" in Windows Explorer and drag-and-drop the dll into this folder OR b) install via command line: "%programfiles%\Microsoft SDKs\Windows\v6.0\bin\gacutil.exe" -i "Bytescout.Spreadsheet.dll" NOTE: you may need to change %programfiles%\Microsoft SDKs\Windows\v6.0\bin\ into %programfiles%\Microsoft SDKs\Windows\v6.0A\bin\ or into %programfiles%\Microsoft SDKs\Windows\v7.0A\bin\ If you are still getting "File not found" then run the search for gacutil.exe in "Program Files" folder to find it. 2) Now run Windows Explorer and open "C:\WINDOWS\assembly" to view installed .NET assemblies in the GAC to verify if the dll was installed into the GAC 3) Find the installed and right-click on it and select "Properties" 4) In the Properties window double-click on "Assembly Name" and copy it to your PHP code (see below) 5) In the Properties window double-click on "Public Key Token" and copy it to your PHP code (see below) 6) In the Properties window double-click on "Version" value and copy it to your PHP code (see below) from (4), (5) and (6) you should compose the following string: $dotnetobj = new DOTNET("ASSEMBLYNAME, Version=VERSIONVALUE, Culture=neutral, PublicKeyToken=PUBLICKEYVALUE", "ASSEMBLYNAME.CLASSNAME"); Where ASSEMBLYNAME = the assembly name (like Bytescout.Spreadsheet) VERSIONVALUE = version value you got on step (5) PUBLICKEYVALUE = public key value you got on step (4) CLASSNAME = class name from the dll you want to create (for example, "Spreadsheet") Example for Spreadsheet SDK version 2.4.0.1370: $dotnetobj = new DOTNET("Bytescout.Spreadsheet, Version=2.4.0.1370, Culture=neutral, PublicKeyToken=f7dd1bd9d40a50eb", "Bytescout.Spreadsheet.Spreadsheet"); Then you may use $dotnetobj and call its methods like this: $dotnetobj->SomeMethod() (see the documentation of the SDK for available classes and methods and properties)

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next