how to rotate excel

Topics: Developer Forum, Project Management Forum, User Forum
Nov 14, 2009 at 12:45 PM

how to rotate excel
it should be like right to left.
i'm using excel2007
waiting for reply

Coordinator
Nov 14, 2009 at 12:55 PM

This feature should already be available with the following methods

// set right-to-left column direction
$objWorksheet->setRightToLeft(true);

// set left-to-right column direction (the default)
$objWorksheet->setRightToLeft(false);

// inspect the column direction
$objWorksheet->getRightToLeft(); // true=right-to-left, false=left-to-right

Nov 14, 2009 at 1:46 PM

i hav created object like

require_once 'Classes/PHPExcel/Worksheet.php';

$objWorksheet=new PHPExcel_Worksheet();

and tried method

$objWorksheet->setRightToLeft(true);

but it is not working.

 

 

Coordinator
Nov 14, 2009 at 2:36 PM

 

/** Error reporting */
error_reporting(E_ALL);

/** PHPExcel */
require_once './Classes/PHPExcel.php';
/** PHPExcel_IOFactory */
require_once './Classes/PHPExcel/IOFactory.php';

// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Set properties
$objPHPExcel->getProperties()->setCreator("Mark Baker")
                             ->setLastModifiedBy("Mark Baker")
                             ->setTitle("Office 2007 XLSX Test Document")
                             ->setSubject("Office 2007 XLSX Test Document")
                             ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
                             ->setKeywords("office 2007 openxml php")
                             ->setCategory("Test result file");

// Add some data
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', 'Hello')
            ->setCellValue('B2', 'world!')
            ->setCellValue('C1', 'Hello')
            ->setCellValue('D2', 'world!');

// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle('RtL');

// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setRightToLeft(true);

// Save Excel 2007 file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('testFile.xlsx');