new files with folders for new version
This commit is contained in:
parent
01ab0f98d8
commit
982d107cb0
|
@ -0,0 +1 @@
|
|||
.equinox .calendar-header{background-color:#0aa8e3;color:#fff;padding:8px 11px;border-top-left-radius:4px;border-top-right-radius:4px}.equinox .calendar-header:after,.equinox .calendar-header:before{content:" ";display:table}.equinox .calendar-header:after{clear:both}.equinox .calendar-actions{float:left}.equinox .month-label{text-align:right;font-size:24px;float:right}.equinox .month-weeks{border:1px solid #efefef;border-top:none;background-color:#fafafa;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.equinox .week{margin-left:-1px;position:relative}.equinox .week:first-child .day{border-top:none}.equinox .week-events{position:absolute;left:0;top:0;width:100%;list-style:none;padding:0;margin:0;padding-top:26px}.equinox .week-events .slot{margin:0}.equinox .week-events .slot>ul{list-style:none;margin:0;padding:0;display:table;table-layout:fixed;width:100%}.equinox .week-events .slot>ul>li{box-sizing:border-box;display:table-cell;margin:0;padding-left:9px;padding-right:8px;width:14.28571%}.equinox .week-events .slot>ul>li.span-1{width:14.28571%}.equinox .week-events .slot>ul>li.span-2{width:28.57143%}.equinox .week-events .slot>ul>li.span-3{width:42.85714%}.equinox .week-events .slot>ul>li.span-4{width:57.14286%}.equinox .week-events .slot>ul>li.span-5{width:71.42857%}.equinox .week-events .slot>ul>li.span-6{width:85.71429%}.equinox .week-events .slot>ul>li.span-7{width:100%}.equinox .week-events .event .start-time{display:none}.equinox .week-events .event .title{white-space:nowrap}.equinox .days-container{display:table;table-layout:fixed;width:100%}.equinox .days-container .day{box-sizing:border-box;display:table-cell;width:14.28571%;padding:8px;border-left:1px solid #efefef;border-top:1px solid #efefef}.equinox .week-header{font-size:10px;text-transform:uppercase;color:#aaa}.equinox .week-header .day{text-align:center;background-color:#fff;text-overflow:ellipsis;overflow:hidden}.equinox .date.outside-month .date-label{color:#d7d7d7}.equinox .date.current-date{background-color:#e7f6fc;position:relative}.equinox .date.current-date:before{content:"";position:absolute;display:block;left:-1px;top:-1px;right:-1px;bottom:-1px;border:1px solid #ceeef9;z-index:1}.equinox .date.current-date .date-label{color:#0aa8e3}.equinox .date-label{text-align:right;font-size:12px;color:#888}.equinox .date-events{list-style:none;padding:0;margin:0;min-height:68px}.equinox .event-container{box-sizing:border-box;min-height:34px;padding-top:6px;margin:0}.equinox .event-container.continuation .event{margin-left:-8px;border-top-left-radius:0;border-bottom-left-radius:0;border-left:none;padding-left:17px}.equinox .event-container.continued .event{margin-right:-8px;border-top-right-radius:0;border-bottom-right-radius:0;padding-right:14px}.equinox .event{display:block;box-sizing:border-box;min-height:28px;background-color:#fff;padding:7px 6px;font-size:12px;line-height:14px;border-radius:3px;box-shadow:0 1px 1px fade(#efefef,80%);border-left:3px solid #ffaa3c;color:#666;position:relative;z-index:2}.equinox .event .start-time{display:none;float:right;color:#bbb;margin-left:4px}.equinox .event .title{display:block;overflow-x:hidden;text-overflow:ellipsis}
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
add_action( 'admin_notices', 'export_btn' );
|
||||
function export_btn() {
|
||||
global $typenow;
|
||||
if ($typenow == 'mep_events_attendees') {
|
||||
?>
|
||||
|
||||
<div class="wrap alignright">
|
||||
<form method='get' action="edit.php">
|
||||
<input type="hidden" name='post_type' value="mep_events_attendees"/>
|
||||
<input type="hidden" name='noheader' value="1"/>
|
||||
<?php
|
||||
if ( isset( $_GET['meta_value'] )) {
|
||||
?>
|
||||
<input type="hidden" name='meta_value' value="<?php echo $_GET['meta_value']; ?>"/>
|
||||
<?php } ?>
|
||||
<input style="display:none" type="radio" name='format' id="formatCSV" value="csv" checked="checked"/>
|
||||
<input type="submit" name='export' id="csvExport" value="Export to CSV"/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
spee_dashboard();
|
||||
function spee_dashboard() {
|
||||
global $wpdb;
|
||||
if ( isset( $_GET['export'] )) {
|
||||
|
||||
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Set document properties
|
||||
|
||||
// Add some data
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Unique ID');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Full Name');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Email');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Phone');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E1', 'Addresss');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F1', 'Tee Size');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('G1', 'Ticket');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('H1', 'Event');
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getStyle('A1:H1')->getFont()->setBold(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimensionByColumn('A:H')->setAutoSize(true);
|
||||
|
||||
|
||||
|
||||
if(isset($_GET['meta_value'])){
|
||||
$meta = $_GET['meta_value'];
|
||||
$query = "SELECT post_id
|
||||
FROM {$wpdb->prefix}postmeta
|
||||
WHERE meta_value = $meta
|
||||
ORDER BY meta_id ASC";
|
||||
}else{
|
||||
$query = "SELECT ID
|
||||
FROM {$wpdb->prefix}posts
|
||||
WHERE post_type ='mep_events_attendees'
|
||||
ORDER BY ID ASC";
|
||||
}
|
||||
|
||||
$posts = $wpdb->get_results($query);
|
||||
if ( $posts ) {
|
||||
foreach ( $posts as $i=>$post ) {
|
||||
if(isset($_GET['meta_value'])){
|
||||
$post_id = $post->post_id;
|
||||
}else{
|
||||
$post_id = $post->ID;
|
||||
}
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A'.($i+2), get_post_meta( $post_id, 'ea_user_id', true ).get_post_meta( $post_id, 'ea_order_id', true ).$post_id);
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('B'.($i+2), get_post_meta( $post_id, 'ea_name', true ));
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('C'.($i+2), get_post_meta( $post_id, 'ea_email', true ));
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('D'.($i+2), get_post_meta( $post_id, 'ea_phone', true ));
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('E'.($i+2), get_post_meta( $post_id, 'ea_address_1', true )."<br/>".get_post_meta( $post_id, 'ea_address_2', true )."<br/>".get_post_meta( $post_id, 'ea_state', true ).", ".get_post_meta( $post_id, 'ea_city', true ).", ".get_post_meta( $post_id, 'ea_country', true ));
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('F'.($i+2), get_post_meta( $post_id, 'ea_tshirtsize', true ));
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('G'.($i+2), get_post_meta( $post_id, 'ea_ticket_type', true ));
|
||||
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('H'.($i+2), get_post_meta( $post_id, 'ea_event_name', true ));
|
||||
}
|
||||
}
|
||||
|
||||
// Rename worksheet
|
||||
//$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
// Redirect output to a client’s web browser
|
||||
ob_clean();
|
||||
ob_start();
|
||||
switch ( $_GET['format'] ) {
|
||||
case 'csv':
|
||||
// Redirect output to a client’s web browser (CSV)
|
||||
header("Content-type: text/csv");
|
||||
header("Cache-Control: no-store, no-cache");
|
||||
header('Content-Disposition: attachment; filename="export.csv"');
|
||||
$objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
|
||||
$objWriter->setDelimiter(',');
|
||||
$objWriter->setEnclosure('"');
|
||||
$objWriter->setLineEnding("\r\n");
|
||||
//$objWriter->setUseBOM(true);
|
||||
$objWriter->setSheetIndex(0);
|
||||
$objWriter->save('php://output');
|
||||
break;
|
||||
case 'xls':
|
||||
// Redirect output to a client’s web browser (Excel5)
|
||||
header('Content-Type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment;filename="export.xls"');
|
||||
header('Cache-Control: max-age=0');
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save('php://output');
|
||||
break;
|
||||
case 'xlsx':
|
||||
// Redirect output to a client’s web browser (Excel2007)
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="export.xlsx"');
|
||||
header('Cache-Control: max-age=0');
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save('php://output');
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
// Enqueue Scripts for admin dashboard
|
||||
add_action('admin_enqueue_scripts', 'mep_event_admin_scripts');
|
||||
function mep_event_admin_scripts() {
|
||||
$user_api = mep_get_option( 'google-map-api', 'general_setting_sec', '');
|
||||
wp_enqueue_script('jquery-ui-datepicker');
|
||||
wp_enqueue_script('jquery-ui-core');
|
||||
wp_enqueue_script('jquery-ui-timepicker-addon',plugin_dir_url( __DIR__ ).'js/jquery-ui-timepicker-addon.js',array('jquery','jquery-ui-core'),1,true);
|
||||
wp_enqueue_script('jquery-ui-timepicker-addon',plugin_dir_url( __DIR__ ).'js/jquery-ui-sliderAccess.js',array('jquery','jquery-ui-core','jquery-ui-timepicker-addon'),1,true);
|
||||
wp_enqueue_style('jquery-ui-timepicker-addon',plugin_dir_url( __DIR__ ).'css/jquery-ui-timepicker-addon.css',array());
|
||||
|
||||
wp_enqueue_style('mep-admin-style',plugin_dir_url( __DIR__ ).'css/admin_style.css',array());
|
||||
|
||||
wp_enqueue_style('mep-jquery-ui-style',plugin_dir_url( __DIR__ ).'css/jquery-ui.css',array());
|
||||
|
||||
|
||||
wp_enqueue_script('gmap-scripts',plugin_dir_url( __DIR__ ).'js/mkb-admin.js',array('jquery','jquery-ui-core'),1,true);
|
||||
|
||||
|
||||
|
||||
|
||||
if($user_api){
|
||||
wp_enqueue_script('gmap-libs','https://maps.googleapis.com/maps/api/js?key='.$user_api.'&libraries=places&callback=initMap',array('jquery','gmap-scripts'),1,true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Enqueue Scripts for frontend
|
||||
add_action('wp_enqueue_scripts', 'mep_event_enqueue_scripts');
|
||||
function mep_event_enqueue_scripts() {
|
||||
wp_enqueue_script('jquery');
|
||||
wp_enqueue_style('mep-event-style',plugin_dir_url( __DIR__ ).'css/style.css',array());
|
||||
wp_enqueue_style ('font-awesome-css-cdn',"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css",null,1);
|
||||
|
||||
wp_enqueue_style('mep-calendar-min-style',plugin_dir_url( __DIR__ ).'css/calendar.min.css',array());
|
||||
|
||||
wp_enqueue_script('mep-moment-js',plugin_dir_url( __DIR__ ).'js/moment.js',array(),1,true);
|
||||
|
||||
wp_enqueue_script('mep-calendar-scripts',plugin_dir_url( __DIR__ ).'js/calendar.min.js',array('jquery','mep-moment-js'),1,false);
|
||||
|
||||
// wp_enqueue_script('mep-event-scripts',plugin_dir_url( __DIR__ ).'js/events.js',array(),1,true);
|
||||
|
||||
wp_enqueue_script('mep-mixitup-min-js',plugin_dir_url( __DIR__ ).'js/mixitup.min.js',array(),1,true);
|
||||
|
||||
wp_enqueue_script('mep-event-custom-scripts',plugin_dir_url( __DIR__ ).'js/mkb-scripts.js',array(),1,true);
|
||||
|
||||
}
|
||||
|
||||
// Enqueue Scripts for frontend
|
||||
add_action('at_footer', 'mep_event_custom_enqueue_scripts');
|
||||
function mep_event_custom_enqueue_scripts() {
|
||||
wp_enqueue_script('jquery-barcode',plugin_dir_url( __DIR__ ).'js/jquery-barcode.min.js',array('jquery'),1,true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Datepicker code for admin dashboard load in footer section
|
||||
add_action('admin_footer','mep_admin_footer_script',10,99);
|
||||
function mep_admin_footer_script(){
|
||||
global $pagenow, $typenow;
|
||||
if ($typenow=='mep_events') {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
var startDateTextBox = jQuery('.event_start');
|
||||
var endDateTextBox = jQuery('.event_end');
|
||||
jQuery.timepicker.datetimeRange(
|
||||
startDateTextBox,
|
||||
endDateTextBox,
|
||||
{
|
||||
minInterval: (1000*60*60), // 1hr
|
||||
dateFormat: 'dd M yy',
|
||||
timeFormat: 'HH:mm',
|
||||
start: {}, // start picker options
|
||||
end: {} // end picker options
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,75 @@
|
|||
(function($) {
|
||||
"use strict";
|
||||
var options = {
|
||||
events_source: 'event.php',
|
||||
view: 'month',
|
||||
tmpl_path: 'tmpls/',
|
||||
tmpl_cache: false,
|
||||
day: '2018-02-28',
|
||||
onAfterEventsLoad: function(events) {
|
||||
if(!events) {
|
||||
return;
|
||||
}
|
||||
var list = $('#eventlist');
|
||||
list.html('');
|
||||
|
||||
$.each(events, function(key, val) {
|
||||
$(document.createElement('li'))
|
||||
.html('<a href="' + val.url + '">' + val.title + '</a>')
|
||||
.appendTo(list);
|
||||
});
|
||||
},
|
||||
onAfterViewLoad: function(view) {
|
||||
$('.page-header h3').text(this.getTitle());
|
||||
$('.btn-group button').removeClass('active');
|
||||
$('button[data-calendar-view="' + view + '"]').addClass('active');
|
||||
},
|
||||
classes: {
|
||||
months: {
|
||||
general: 'label'
|
||||
}
|
||||
}
|
||||
};
|
||||
var calendar = $('#showEventCalendar').calendar(options);
|
||||
$('.btn-group button[data-calendar-nav]').each(function() {
|
||||
var $this = $(this);
|
||||
$this.click(function() {
|
||||
calendar.navigate($this.data('calendar-nav'));
|
||||
});
|
||||
});
|
||||
$('.btn-group button[data-calendar-view]').each(function() {
|
||||
var $this = $(this);
|
||||
$this.click(function() {
|
||||
calendar.view($this.data('calendar-view'));
|
||||
});
|
||||
});
|
||||
$('#first_day').change(function(){
|
||||
var value = $(this).val();
|
||||
value = value.length ? parseInt(value) : null;
|
||||
calendar.setOptions({first_day: value});
|
||||
calendar.view();
|
||||
});
|
||||
$('#language').change(function(){
|
||||
calendar.setLanguage($(this).val());
|
||||
calendar.view();
|
||||
});
|
||||
$('#events-in-modal').change(function(){
|
||||
var val = $(this).is(':checked') ? $(this).val() : null;
|
||||
calendar.setOptions({modal: val});
|
||||
});
|
||||
$('#format-12-hours').change(function(){
|
||||
var val = $(this).is(':checked') ? true : false;
|
||||
calendar.setOptions({format12: val});
|
||||
calendar.view();
|
||||
});
|
||||
$('#show_wbn').change(function(){
|
||||
var val = $(this).is(':checked') ? true : false;
|
||||
calendar.setOptions({display_week_numbers: val});
|
||||
calendar.view();
|
||||
});
|
||||
$('#show_wb').change(function(){
|
||||
var val = $(this).is(':checked') ? true : false;
|
||||
calendar.setOptions({weekbox: val});
|
||||
calendar.view();
|
||||
});
|
||||
}(jQuery));
|
|
@ -0,0 +1,154 @@
|
|||
|
||||
|
||||
window.google = window.google || {};
|
||||
google.maps = google.maps || {};
|
||||
(function() {
|
||||
|
||||
function getScript(src) {
|
||||
document.write('<' + 'script src="' + src + '"><' + '/script>');
|
||||
}
|
||||
|
||||
var modules = google.maps.modules = {};
|
||||
google.maps.__gjsload__ = function(name, text) {
|
||||
modules[name] = text;
|
||||
};
|
||||
|
||||
google.maps.Load = function(apiLoad) {
|
||||
delete google.maps.Load;
|
||||
apiLoad([0.009999999776482582,[null,[["https://khms0.googleapis.com/kh?v=800\u0026hl=en-US\u0026","https://khms1.googleapis.com/kh?v=800\u0026hl=en-US\u0026"],null,null,null,1,"800",["https://khms0.google.com/kh?v=800\u0026hl=en-US\u0026","https://khms1.google.com/kh?v=800\u0026hl=en-US\u0026"]],null,null,null,null,[["https://cbks0.googleapis.com/cbk?","https://cbks1.googleapis.com/cbk?"]],[["https://khms0.googleapis.com/kh?v=115\u0026hl=en-US\u0026","https://khms1.googleapis.com/kh?v=115\u0026hl=en-US\u0026"],null,null,null,null,"115",["https://khms0.google.com/kh?v=115\u0026hl=en-US\u0026","https://khms1.google.com/kh?v=115\u0026hl=en-US\u0026"]],[["https://mts0.googleapis.com/mapslt?hl=en-US\u0026","https://mts1.googleapis.com/mapslt?hl=en-US\u0026"]],null,null,null,[["https://mts0.googleapis.com/mapslt?hl=en-US\u0026","https://mts1.googleapis.com/mapslt?hl=en-US\u0026"]]],["en-US","US",null,0,null,null,"https://maps.gstatic.com/mapfiles/","https://csi.gstatic.com","https://maps.googleapis.com","https://maps.googleapis.com",null,"https://maps.google.com","https://gg.google.com","https://maps.gstatic.com/maps-api-v3/api/images/","https://www.google.com/maps",0,"https://www.google.com"],["https://maps.googleapis.com/maps-api-v3/api/js/32/13","3.32.13"],[418431435],1,null,null,null,null,null,"",null,null,1,"https://khms.googleapis.com/mz?v=800\u0026",null,"https://earthbuilder.googleapis.com","https://earthbuilder.googleapis.com",null,"https://mts.googleapis.com/maps/vt/icon",[["https://maps.googleapis.com/maps/vt"],["https://maps.googleapis.com/maps/vt"],null,null,null,null,null,null,null,null,null,null,["https://www.google.com/maps/vt"],"/maps/vt",421000000,421],2,500,[null,null,null,null,"https://www.google.com/maps/preview/log204","","https://static.panoramio.com.storage.googleapis.com/photos/",["https://geo0.ggpht.com/cbk","https://geo1.ggpht.com/cbk","https://geo2.ggpht.com/cbk","https://geo3.ggpht.com/cbk"],"https://maps.googleapis.com/maps/api/js/GeoPhotoService.GetMetadata","https://maps.googleapis.com/maps/api/js/GeoPhotoService.SingleImageSearch",["https://lh3.ggpht.com/","https://lh4.ggpht.com/","https://lh5.ggpht.com/","https://lh6.ggpht.com/"]],null,null,null,null,"/maps/api/js/ApplicationService.GetEntityDetails",0,null,null,[null,null,null,null,null,null,null,null,null,[0,0]],null,[],["32.13"],1,5000], loadScriptTime);
|
||||
};
|
||||
var loadScriptTime = (new Date).getTime();
|
||||
})();
|
||||
// inlined
|
||||
(function(_){var ta,xa,za,Ba,Ca,Da,Pa,Qa,bb,gb,hb,jb,ob,nb,pb,qb,Hb,Jb,Nb,Ub,Xb,Yb,hc,lc,pc,Cc,Dc,Ec,Fc,Hc,Ic,Lc,Oc,Kc,Pc,Sc,Yc,id,kd,md,pd,rd,qd,Ad,Ed,Gd,Jd,Kd,Nd,Pd,Rd,Ld,Od,Vd,Yd,Zd,ne,oe,pe,re,se,ve,we,Ae,Be,Ce,De,Ge,Ie,Je,Te,Ue,Ve,We,Ye,Ze,lf,mf,nf,uf,vf,wf,xf,yf,Ef,Ff,Mf,Of,Pf,Qf,Wf,Uf,Zf,$f,bg,eg,gg,fg,ig,mg,og,tg,ug,xg,yg,zg,Ag,Bg,Dg,wa,va,Ma,Na;_.aa="ERROR";_.ba="INVALID_REQUEST";_.ca="MAX_DIMENSIONS_EXCEEDED";_.da="MAX_ELEMENTS_EXCEEDED";_.ea="MAX_WAYPOINTS_EXCEEDED";_.fa="NOT_FOUND";_.ha="OK";
|
||||
_.ia="OVER_QUERY_LIMIT";_.ka="REQUEST_DENIED";_.la="UNKNOWN_ERROR";_.ma="ZERO_RESULTS";_.na=function(){return function(a){return a}};_.l=function(){return function(){}};_.oa=function(a){return function(b){this[a]=b}};_.pa=function(a){return function(){return this[a]}};_.qa=function(a){return function(){return a}};_.sa=function(a){return function(){return _.ra[a].apply(this,arguments)}};ta=function(){ta=_.l();_.ua.Symbol||(_.ua.Symbol=va)};
|
||||
_.ya=function(){ta();var a=_.ua.Symbol.iterator;a||(a=_.ua.Symbol.iterator=_.ua.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&wa(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return xa(this)}});_.ya=_.l()};xa=function(a){var b=0;return za(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})};za=function(a){(0,_.ya)();a={next:a};a[_.ua.Symbol.iterator]=function(){return this};return a};
|
||||
_.Aa=function(a){(0,_.ya)();var b=a[window.Symbol.iterator];return b?b.call(a):xa(a)};Ba=function(a,b,c){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var f=a[e];if(b.call(c,f,e,a))return{Ae:e,Si:f}}return{Ae:-1,Si:void 0}};Ca=function(a,b){if(b){var c=_.ua;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&wa(c,a,{configurable:!0,writable:!0,value:b})}};
|
||||
Da=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};_.q=function(a){return void 0!==a};_.Ea=function(a){return"string"==typeof a};_.Fa=function(a){return"number"==typeof a};_.Ga=_.l();
|
||||
_.Ha=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
|
||||
else if("function"==b&&"undefined"==typeof a.call)return"object";return b};_.Ia=function(a){return"array"==_.Ha(a)};_.Ja=function(a){var b=_.Ha(a);return"array"==b||"object"==b&&"number"==typeof a.length};_.Ka=function(a){return"function"==_.Ha(a)};_.La=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b};_.Oa=function(a){return a[Ma]||(a[Ma]=++Na)};Pa=function(a,b,c){return a.call.apply(a.bind,arguments)};
|
||||
Qa=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}};_.v=function(a,b,c){Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?_.v=Pa:_.v=Qa;return _.v.apply(null,arguments)};_.Ra=function(){return+new Date};
|
||||
_.z=function(a,b){function c(){}c.prototype=b.prototype;a.Eb=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.vf=function(a,c,f){for(var d=Array(arguments.length-2),e=2;e<arguments.length;e++)d[e-2]=arguments[e];b.prototype[c].apply(a,d)}};_.Sa=function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(_.Ea(a))return _.Ea(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1};
|
||||
_.A=function(a,b,c){for(var d=a.length,e=_.Ea(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)};_.Ta=function(a,b,c){for(var d=a.length,e=_.Ea(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&b.call(c,e[f],f,a))return f;return-1};_.Va=function(a,b){b=_.Sa(a,b);var c;(c=0<=b)&&_.Ua(a,b);return c};_.Ua=function(a,b){Array.prototype.splice.call(a,b,1)};_.Xa=function(a,b,c){return 2>=arguments.length?Array.prototype.slice.call(a,b):Array.prototype.slice.call(a,b,c)};_.Za=function(){return-1!=_.Ya.toLowerCase().indexOf("webkit")};
|
||||
_.$a=function(a){return-1!=_.Ya.indexOf(a)};_.ab=function(){return _.$a("Trident")||_.$a("MSIE")};_.cb=function(){return _.$a("Safari")&&!(bb()||_.$a("Coast")||_.$a("Opera")||_.$a("Edge")||_.$a("Silk")||_.$a("Android"))};bb=function(){return(_.$a("Chrome")||_.$a("CriOS"))&&!_.$a("Edge")};_.db=function(){return _.$a("Android")&&!(bb()||_.$a("Firefox")||_.$a("Opera")||_.$a("Silk"))};_.eb=function(){return _.$a("iPhone")&&!_.$a("iPod")&&!_.$a("iPad")};_.fb=function(a){_.fb[" "](a);return a};
|
||||
gb=function(){var a=_.C.document;return a?a.documentMode:void 0};hb=function(a,b){this.j=a;this.l=b;this.f=0;this.b=null};_.ib=_.na();jb=function(a){_.C.setTimeout(function(){throw a;},0)};ob=function(){var a=_.kb.f;a=lb(a);!_.Ka(_.C.setImmediate)||_.C.Window&&_.C.Window.prototype&&!_.$a("Edge")&&_.C.Window.prototype.setImmediate==_.C.setImmediate?(mb||(mb=nb()),mb(a)):_.C.setImmediate(a)};
|
||||
nb=function(){var a=_.C.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!_.$a("Presto")&&(a=function(){var a=window.document.createElement("IFRAME");a.style.display="none";a.src="";window.document.documentElement.appendChild(a);var b=a.contentWindow;a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host;a=(0,_.v)(function(a){if(("*"==
|
||||
d||a.origin==d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&!_.ab()){var b=new a,c={},d=c;b.port1.onmessage=function(){if(_.q(c.next)){c=c.next;var a=c.nh;c.nh=null;a()}};return function(a){d.next={nh:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof window.document&&"onreadystatechange"in window.document.createElement("SCRIPT")?function(a){var b=window.document.createElement("SCRIPT");
|
||||
b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};window.document.documentElement.appendChild(b)}:function(a){_.C.setTimeout(a,0)}};pb=function(){this.f=this.b=null};qb=function(){this.next=this.b=this.Zc=null};_.kb=function(a,b){_.kb.b||_.kb.m();_.kb.j||(_.kb.b(),_.kb.j=!0);_.kb.l.add(a,b)};_.rb=function(a){return a*Math.PI/180};_.sb=function(a){return 180*a/Math.PI};_.E=function(a){return a?a.length:0};
|
||||
_.ub=function(a,b){_.tb(b,function(c){a[c]=b[c]})};_.vb=function(a,b,c){null!=b&&(a=Math.max(a,b));null!=c&&(a=Math.min(a,c));return a};_.wb=function(a,b,c){c-=b;return((a-b)%c+c)%c+b};_.xb=function(a,b,c){return Math.abs(a-b)<=(c||1E-9)};_.yb=function(a,b){for(var c=[],d=_.E(a),e=0;e<d;++e)c.push(b(a[e],e));return c};_.Bb=function(a,b){for(var c=_.Ab(void 0,_.E(b)),d=_.Ab(void 0,0);d<c;++d)a.push(b[d])};_.F=function(a){return"number"==typeof a};_.Cb=function(a){return"object"==typeof a};
|
||||
_.Ab=function(a,b){return null==a?b:a};_.Db=function(a){return"string"==typeof a};_.Eb=function(a){return a===!!a};_.tb=function(a,b){for(var c in a)b(c,a[c])};_.Gb=function(a){return function(){var b=this,c=arguments;_.Fb(function(){a.apply(b,c)})}};_.Fb=function(a){return window.setTimeout(a,0)};Hb=function(a,b){if(Object.prototype.hasOwnProperty.call(a,b))return a[b]};_.Ib=function(a){_.C.console&&_.C.console.error&&_.C.console.error(a)};
|
||||
Jb=function(a){this.message=a;this.name="InvalidValueError";this.stack=Error().stack};_.Kb=function(a,b){var c="";if(null!=b){if(!(b instanceof Jb))return b;c=": "+b.message}return new Jb(a+c)};_.Lb=function(a){if(!(a instanceof Jb))throw a;_.Ib(a.name+": "+a.message)};
|
||||
_.Mb=function(a,b){var c=c?c+": ":"";return function(d){if(!d||!_.Cb(d))throw _.Kb(c+"not an Object");var e={},f;for(f in d)if(e[f]=d[f],!b&&!a[f])throw _.Kb(c+"unknown property "+f);for(f in a)try{var g=a[f](e[f]);if(_.q(g)||Object.prototype.hasOwnProperty.call(d,f))e[f]=a[f](e[f])}catch(h){throw _.Kb(c+"in property "+f,h);}return e}};Nb=function(a){try{return!!a.cloneNode}catch(b){return!1}};
|
||||
_.Ob=function(a,b,c){return c?function(c){if(c instanceof a)return c;try{return new a(c)}catch(e){throw _.Kb("when calling new "+b,e);}}:function(c){if(c instanceof a)return c;throw _.Kb("not an instance of "+b);}};_.Pb=function(a){return function(b){for(var c in a)if(a[c]==b)return b;throw _.Kb(b);}};_.Qb=function(a){return function(b){if(!_.Ia(b))throw _.Kb("not an Array");return _.yb(b,function(b,d){try{return a(b)}catch(e){throw _.Kb("at index "+d,e);}})}};
|
||||
_.Rb=function(a,b){return function(c){if(a(c))return c;throw _.Kb(b||""+c);}};_.Sb=function(a){return function(b){for(var c=[],d=0,e=a.length;d<e;++d){var f=a[d];try{(f.Lg||f)(b)}catch(g){if(!(g instanceof Jb))throw g;c.push(g.message);continue}return(f.then||f)(b)}throw _.Kb(c.join("; and "));}};_.Tb=function(a,b){return function(c){return b(a(c))}};_.G=function(a){return function(b){return null==b?b:a(b)}};
|
||||
Ub=function(a){return function(b){if(b&&null!=b[a])return b;throw _.Kb("no "+a+" property");}};_.H=function(a,b){this.x=a;this.y=b};Xb=function(a){if(a instanceof _.H)return a;try{_.Mb({x:_.Wb,y:_.Wb},!0)(a)}catch(b){throw _.Kb("not a Point",b);}return new _.H(a.x,a.y)};_.J=function(a,b,c,d){this.width=a;this.height=b;this.f=c||"px";this.b=d||"px"};Yb=function(a){if(a instanceof _.J)return a;try{_.Mb({height:_.Wb,width:_.Wb},!0)(a)}catch(b){throw _.Kb("not a Size",b);}return new _.J(a.width,a.height)};
|
||||
_.Zb=function(a,b){this.J=a;this.K=b};_.$b=function(a){this.min=0;this.max=a;this.b=a-0};_.ac=function(a){this.Mc=a.Mc||null;this.Nc=a.Nc||null};_.bc=function(a,b,c){this.b=a;a=Math.cos(b*Math.PI/180);b=Math.cos(c*Math.PI/180);c=Math.sin(c*Math.PI/180);this.m11=this.b*b;this.m12=this.b*c;this.m21=-this.b*a*c;this.m22=this.b*a*b;this.f=this.m11*this.m22-this.m12*this.m21};_.cc=function(a,b,c){var d=Math.pow(2,Math.round(a))/256;return new _.bc(Math.round(Math.pow(2,a)/d)*d,b,c)};
|
||||
_.dc=function(a,b){return new _.Zb((a.m22*b.W-a.m12*b.Y)/a.f,(-a.m21*b.W+a.m11*b.Y)/a.f)};_.fc=function(a){this.R=this.O=window.Infinity;this.V=this.T=-window.Infinity;_.A(a||[],this.extend,this)};_.gc=function(a,b,c,d){var e=new _.fc;e.O=a;e.R=b;e.T=c;e.V=d;return e};hc=function(a,b){-180==a&&180!=b&&(a=180);-180==b&&180!=a&&(b=180);this.b=a;this.f=b};_.ic=function(a){return a.b>a.f};_.jc=function(a,b){var c=b-a;return 0<=c?c:b+180-(a-180)};
|
||||
_.kc=function(a){return a.isEmpty()?0:_.ic(a)?360-(a.b-a.f):a.f-a.b};lc=function(a,b){this.b=a;this.f=b};_.K=function(a,b,c){if(a&&(void 0!==a.lat||void 0!==a.lng))try{mc(a),b=a.lng,a=a.lat,c=!1}catch(d){_.Lb(d)}a-=0;b-=0;c||(a=_.vb(a,-90,90),180!=b&&(b=_.wb(b,-180,180)));this.lat=function(){return a};this.lng=function(){return b}};_.nc=function(a){return _.rb(a.lat())};_.oc=function(a){return _.rb(a.lng())};pc=function(a,b){b=Math.pow(10,b);return Math.round(a*b)/b};
|
||||
_.qc=function(a){try{if(a instanceof _.K)return a;a=mc(a);return new _.K(a.lat,a.lng)}catch(b){throw _.Kb("not a LatLng or LatLngLiteral",b);}};_.rc=function(a,b){a=a&&_.qc(a);b=b&&_.qc(b);if(a){b=b||a;var c=_.vb(a.lat(),-90,90),d=_.vb(b.lat(),-90,90);this.f=new lc(c,d);a=a.lng();b=b.lng();360<=b-a?this.b=new hc(-180,180):(a=_.wb(a,-180,180),b=_.wb(b,-180,180),this.b=new hc(a,b))}else this.f=new lc(1,-1),this.b=new hc(180,-180)};_.sc=function(a,b,c,d){return new _.rc(new _.K(a,b,!0),new _.K(c,d,!0))};
|
||||
_.uc=function(a){if(a instanceof _.rc)return a;try{return a=tc(a),_.sc(a.south,a.west,a.north,a.east)}catch(b){throw _.Kb("not a LatLngBounds or LatLngBoundsLiteral",b);}};_.Ac=function(a){a=a||window.event;_.vc(a);_.xc(a)};_.vc=function(a){a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation()};_.xc=function(a){a.preventDefault&&_.q(a.defaultPrevented)?a.preventDefault():a.returnValue=!1};_.Bc=function(a){a.handled=!0;void 0===a.bubbles&&(a.returnValue="handled")};
|
||||
Cc=function(a,b){a.__e3_||(a.__e3_={});a=a.__e3_;a[b]||(a[b]={});return a[b]};Dc=function(a,b){var c=a.__e3_||{};if(b)a=c[b]||{};else for(b in a={},c)_.ub(a,c[b]);return a};Ec=function(a,b){return function(c){return b.call(a,c,this)}};Fc=function(a,b,c){return function(d){var e=[b,a];_.Bb(e,arguments);_.M.trigger.apply(this,e);c&&_.Bc.apply(null,arguments)}};Hc=function(a,b,c,d){this.f=a;this.j=b;this.b=c;this.l=d;this.id=++Gc;Cc(a,b)[this.id]=this};
|
||||
Ic=function(a){return function(b){b||(b=window.event);if(b&&!b.target)try{b.target=b.srcElement}catch(d){}var c=a.b.apply(a.f,[b]);return b&&"click"==b.type&&(b=b.srcElement)&&"A"==b.tagName&&"javascript:void(0)"==b.href?!1:c}};_.Jc=function(a){return""+(_.La(a)?_.Oa(a):a)};_.N=_.l();Lc=function(a,b){var c=b+"_changed";if(a[c])a[c]();else a.changed(b);c=Kc(a,b);for(var d in c){var e=c[d];Lc(e.gd,e.Cb)}_.M.trigger(a,b.toLowerCase()+"_changed")};
|
||||
_.Nc=function(a){return Mc[a]||(Mc[a]=a.substr(0,1).toUpperCase()+a.substr(1))};Oc=function(a){a.gm_accessors_||(a.gm_accessors_={});return a.gm_accessors_};Kc=function(a,b){a.gm_bindings_||(a.gm_bindings_={});a.gm_bindings_.hasOwnProperty(b)||(a.gm_bindings_[b]={});return a.gm_bindings_[b]};Pc=function(a){this.P=[];this.b=a&&a.Od||_.Ga;this.f=a&&a.Pd||_.Ga};
|
||||
_.Rc=function(a,b,c,d){function e(){_.A(f,function(a){b.call(c||null,function(b){if(a.once){if(a.once.kh)return;a.once.kh=!0;_.Va(g.P,a);g.P.length||g.b()}a.Zc.call(a.context,b)})})}var f=a.P.slice(0),g=a;d&&d.sync?e():Qc(e)};Sc=function(a,b){return function(c){return c.Zc==a&&c.context==(b||null)}};_.Tc=function(){this.P=new Pc({Od:(0,_.v)(this.Od,this),Pd:(0,_.v)(this.Pd,this)})};_.Uc=function(a,b){a.P.addListener(b,void 0);b.call(void 0,a.get())};_.Vc=function(a){return function(){return this.get(a)}};
|
||||
_.Wc=function(a,b){return b?function(c){try{this.set(a,b(c))}catch(d){_.Lb(_.Kb("set"+_.Nc(a),d))}}:function(b){this.set(a,b)}};_.Xc=function(a,b){_.tb(b,function(b,d){var c=_.Vc(b);a["get"+_.Nc(b)]=c;d&&(d=_.Wc(b,d),a["set"+_.Nc(b)]=d)})};_.Zc=function(a){this.b=a||[];Yc(this)};Yc=function(a){a.set("length",a.b.length)};_.$c=function(){this.f={};this.j=0};_.bd=function(a,b){var c=a.f,d=_.Jc(b);c[d]||(c[d]=b,++a.j,_.M.trigger(a,"insert",b),a.b&&a.b(b))};_.cd=_.oa("b");
|
||||
_.dd=function(a,b,c){this.heading=a;this.pitch=_.vb(b,-90,90);this.zoom=Math.max(0,c)};_.gd=function(){this.__gm=new _.N;this.l=null};_.hd=function(a){_.Tc.call(this);this.m=!!a};_.jd=function(a,b){return new id(a,b)};id=function(a,b){_.hd.call(this,b);this.b=a};kd=_.l();_.ld=function(a,b){a[b]||(a[b]=[]);return a[b]};
|
||||
_.nd=function(a,b){if(null==a||null==b)return null==a==(null==b);if(a.constructor!=Array&&a.constructor!=Object)throw Error("Invalid object type passed into jsproto.areObjectsEqual()");if(a===b)return!0;if(a.constructor!=b.constructor)return!1;for(var c in a)if(!(c in b&&md(a[c],b[c])))return!1;for(var d in b)if(!(d in a))return!1;return!0};
|
||||
md=function(a,b){if(a===b||!(!0!==a&&1!==a||!0!==b&&1!==b)||!(!1!==a&&0!==a||!1!==b&&0!==b))return!0;if(a instanceof Object&&b instanceof Object){if(!_.nd(a,b))return!1}else return!1;return!0};_.od=function(a){_.Ea(a)?this.b=a:(this.b=a.C,this.f=a.G);this.Qb=1==(0,window.parseInt)(this.b,10)?0:-1};pd=_.l();rd=function(a,b,c){var d=new _.od(b);d.forEach(function(b){var e=b.Nd,g=a[e+d.Qb];if(null!=g)if(b.Vd)for(var h=0;h<g.length;++h)qd(g[h],e,b,c);else qd(g,e,b,c)})};
|
||||
qd=function(a,b,c,d){if("m"==c.type){var e=d.length;rd(a,c.Zd,d);d.splice(e,0,[b,"m",d.length-e].join(""))}else"b"==c.type&&(a=a?"1":"0"),a=[b,c.type,(0,window.encodeURIComponent)(a)].join(""),d.push(a)};_.O=function(a){this.data=a||[]};_.td=function(a,b,c){a=a.data[b];return null!=a?a:c};_.ud=function(a,b,c){return _.td(a,b,c||0)};_.P=function(a,b,c){return _.td(a,b,c||0)};_.Q=function(a,b,c){return _.td(a,b,c||"")};_.R=function(a,b){var c=a.data[b];c||(c=a.data[b]=[]);return c};
|
||||
_.vd=function(a,b){return _.ld(a.data,b)};_.wd=function(a,b,c){_.vd(a,b).push(c)};_.xd=function(a,b,c){return _.vd(a,b)[c]};_.yd=function(a,b){var c=[];_.vd(a,b).push(c);return c};_.zd=function(a,b){return a.data[b]?a.data[b].length:0};Ad=_.l();_.Bd=_.oa("__gm");_.Dd=function(){this.cg=Cd()+(Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^_.Ra()).toString(36))};Ed=_.l();_.Fd=function(a){this.b=_.qc(a)};
|
||||
Gd=function(a){if(a instanceof Ed)return a;try{return new _.Fd(_.qc(a))}catch(b){}throw _.Kb("not a Geometry or LatLng or LatLngLiteral object");};_.Hd=function(a,b){if(a)return function(){--a||b()};b();return _.Ga};_.Id=function(a,b,c){var d=a.getElementsByTagName("head")[0];a=a.createElement("script");a.type="text/javascript";a.charset="UTF-8";a.src=b;c&&(a.onerror=c);d.appendChild(a);return a};
|
||||
Jd=function(a){for(var b="",c=0,d=arguments.length;c<d;++c){var e=arguments[c];e.length&&"/"==e[0]?b=e:(b&&"/"!=b[b.length-1]&&(b+="/"),b+=e)}return b};Kd=function(a){this.j=window.document;this.b={};this.f=a};Nd=function(){this.l={};this.f={};this.m={};this.b={};this.j=new Ld};Pd=function(a,b){a.l[b]||(a.l[b]=!0,Od(a.j,function(c){for(var d=c.b[b],e=d?d.length:0,f=0;f<e;++f){var g=d[f];a.b[g]||Pd(a,g)}c=c.j;c.b[b]||_.Id(c.j,Jd(c.f,b)+".js")}))};
|
||||
Rd=function(a,b){var c=Qd;this.j=a;this.b=c;a={};for(var d in c)for(var e=c[d],f=0,g=e.length;f<g;++f){var h=e[f];a[h]||(a[h]=[]);a[h].push(d)}this.l=a;this.f=b};Ld=function(){this.b=[]};Od=function(a,b){a.f?b(a.f):a.b.push(b)};_.S=function(a,b,c){var d=Nd.b();a=""+a;d.b[a]?b(d.b[a]):((d.f[a]=d.f[a]||[]).push(b),c||Pd(d,a))};_.Sd=function(a,b){Nd.b().b[""+a]=b};_.Td=function(a,b,c){var d=[],e=_.Hd(a.length,function(){b.apply(null,d)});_.A(a,function(a,b){_.S(a,function(a){d[b]=a;e()},c)})};
|
||||
_.Ud=function(a){a=a||{};this.j=a.id;this.b=null;try{this.b=a.geometry?Gd(a.geometry):null}catch(b){_.Lb(b)}this.f=a.properties||{}};Vd=function(){this.b={};this.j={};this.f={}};Yd=function(){this.b={}};Zd=function(a){this.b=new Yd;var b=this;_.M.addListenerOnce(a,"addfeature",function(){_.S("data",function(c){c.b(b,a,b.b)})})};_.ae=function(a){this.b=[];try{this.b=$d(a)}catch(b){_.Lb(b)}};_.ce=function(a){this.b=(0,_.be)(a)};_.de=function(a){this.b=(0,_.be)(a)};_.fe=function(a){this.b=ee(a)};
|
||||
_.ge=function(a){this.b=(0,_.be)(a)};_.ie=function(a){this.b=he(a)};_.ke=function(a){this.b=je(a)};
|
||||
_.le=function(a,b,c){function d(a){if(!a)throw _.Kb("not a Feature");if("Feature"!=a.type)throw _.Kb('type != "Feature"');var b=a.geometry;try{b=null==b?null:e(b)}catch(I){throw _.Kb('in property "geometry"',I);}var d=a.properties||{};if(!_.Cb(d))throw _.Kb("properties is not an Object");var f=c.idPropertyName;a=f?d[f]:a.id;if(null!=a&&!_.F(a)&&!_.Db(a))throw _.Kb((f||"id")+" is not a string or number");return{id:a,geometry:b,properties:d}}function e(a){if(null==a)throw _.Kb("is null");var b=(a.type+
|
||||
"").toLowerCase(),c=a.coordinates;try{switch(b){case "point":return new _.Fd(h(c));case "multipoint":return new _.ge(n(c));case "linestring":return g(c);case "multilinestring":return new _.fe(p(c));case "polygon":return f(c);case "multipolygon":return new _.ke(t(c))}}catch(D){throw _.Kb('in property "coordinates"',D);}if("geometrycollection"==b)try{return new _.ae(u(a.geometries))}catch(D){throw _.Kb('in property "geometries"',D);}throw _.Kb("invalid type");}function f(a){return new _.ie(r(a))}function g(a){return new _.ce(n(a))}
|
||||
function h(a){a=k(a);return _.qc({lat:a[1],lng:a[0]})}if(!b)return[];c=c||{};var k=_.Qb(_.Wb),n=_.Qb(h),p=_.Qb(g),r=_.Qb(function(a){a=n(a);if(!a.length)throw _.Kb("contains no elements");if(!a[0].da(a[a.length-1]))throw _.Kb("first and last positions are not equal");return new _.de(a.slice(0,-1))}),t=_.Qb(f),u=_.Qb(e),x=_.Qb(d);if("FeatureCollection"==b.type){b=b.features;try{return _.yb(x(b),function(b){return a.add(b)})}catch(w){throw _.Kb('in property "features"',w);}}if("Feature"==b.type)return[a.add(d(b))];
|
||||
throw _.Kb("not a Feature or FeatureCollection");};ne=function(a){var b=this;a=a||{};this.setValues(a);this.b=new Vd;_.M.forward(this.b,"addfeature",this);_.M.forward(this.b,"removefeature",this);_.M.forward(this.b,"setgeometry",this);_.M.forward(this.b,"setproperty",this);_.M.forward(this.b,"removeproperty",this);this.f=new Zd(this.b);this.f.bindTo("map",this);this.f.bindTo("style",this);_.A(_.me,function(a){_.M.forward(b.f,a,b)});this.j=!1};oe=function(a){a.j||(a.j=!0,_.S("drawing_impl",function(b){b.Gl(a)}))};
|
||||
pe=function(a){if(!a)return null;if(_.Ea(a)){var b=window.document.createElement("div");b.style.overflow="auto";b.innerHTML=a}else a.nodeType==window.Node.TEXT_NODE?(b=window.document.createElement("div"),b.appendChild(a)):b=a;return b};re=function(a){var b=qe,c=Nd.b().j;a=c.f=new Rd(new Kd(a),b);b=0;for(var d=c.b.length;b<d;++b)c.b[b](a);c.b.length=0};se=function(a){a=a||{};a.clickable=_.Ab(a.clickable,!0);a.visible=_.Ab(a.visible,!0);this.setValues(a);_.S("marker",_.Ga)};
|
||||
_.te=function(a){this.__gm={set:null,Be:null,mc:{map:null,We:null}};se.call(this,a)};ve=function(a,b){this.b=a;this.f=b;a.addListener("map_changed",(0,_.v)(this.xm,this));this.bindTo("map",a);this.bindTo("disableAutoPan",a);this.bindTo("maxWidth",a);this.bindTo("position",a);this.bindTo("zIndex",a);this.bindTo("internalAnchor",a,"anchor");this.bindTo("internalContent",a,"content");this.bindTo("internalPixelOffset",a,"pixelOffset")};we=function(a,b,c,d){c?a.bindTo(b,c,d):(a.unbind(b),a.set(b,void 0))};
|
||||
_.xe=function(a){function b(){e||(e=!0,_.S("infowindow",function(a){a.vk(d)}))}window.setTimeout(function(){_.S("infowindow",_.Ga)},100);a=a||{};var c=!!a.b;delete a.b;var d=new ve(this,c),e=!1;_.M.addListenerOnce(this,"anchor_changed",b);_.M.addListenerOnce(this,"map_changed",b);this.setValues(a)};_.ze=function(a){_.ye&&a&&_.ye.push(a)};Ae=function(a){this.setValues(a)};Be=_.l();Ce=_.l();De=_.l();_.Ee=function(){_.S("geocoder",_.Ga)};
|
||||
_.Fe=function(a,b,c){this.F=null;this.set("url",a);this.set("bounds",_.G(_.uc)(b));this.setValues(c)};Ge=function(a,b){_.Db(a)?(this.set("url",a),this.setValues(b)):this.setValues(a)};_.He=function(){var a=this;_.S("layers",function(b){b.b(a)})};Ie=function(a){this.setValues(a);var b=this;_.S("layers",function(a){a.f(b)})};Je=function(){var a=this;_.S("layers",function(b){b.j(a)})};_.Le=function(){this.j="";this.l=_.Ke};_.Me=function(a){var b=new _.Le;b.j=a;return b};
|
||||
_.Oe=function(){this.j="";this.m=_.Ne;this.l=null};_.Qe=function(a,b){var c=new _.Oe;c.j=a;c.l=b;return c};_.Re=function(a,b){b.parentNode&&b.parentNode.insertBefore(a,b.nextSibling)};_.Se=function(a){a&&a.parentNode&&a.parentNode.removeChild(a)};Te=_.l();Ue=function(a,b,c,d,e){this.b=!!b;this.node=null;this.f=0;this.j=!1;this.l=!c;a&&this.setPosition(a,d);this.depth=void 0!=e?e:this.f||0;this.b&&(this.depth*=-1)};Ve=function(a,b,c,d){Ue.call(this,a,b,c,null,d)};We=function(a){this.data=a||[]};
|
||||
_.Xe=function(a){this.data=a||[]};Ye=function(a){this.data=a||[]};Ze=function(a){this.data=a||[]};_.$e=function(a){return _.Q(a,0)};_.af=function(a){return _.Q(a,1)};_.bf=function(){return _.Q(_.T,16)};_.U=function(a){return new We(a.data[2])};_.ef=function(a,b,c){this.size=a;this.ga=b;this.heading=c;this.b=Math.cos(this.ga/180*Math.PI)};_.ff=function(){this.b=new _.H(128,128);this.j=256/360;this.l=256/(2*Math.PI);this.f=!0};
|
||||
_.gf=function(a,b,c){if(a=a.fromLatLngToPoint(b))c=Math.pow(2,c),a.x*=c,a.y*=c;return a};_.hf=function(a,b){var c=a.lat()+_.sb(b);90<c&&(c=90);var d=a.lat()-_.sb(b);-90>d&&(d=-90);b=Math.sin(b);var e=Math.cos(_.rb(a.lat()));if(90==c||-90==d||1E-6>e)return new _.rc(new _.K(d,-180),new _.K(c,180));b=_.sb(Math.asin(b/e));return new _.rc(new _.K(d,a.lng()-b),new _.K(c,a.lng()+b))};
|
||||
lf=function(a,b){_.gd.call(this);_.ze(a);this.__gm=new _.N;this.f=null;b&&b.client&&(this.f=_.jf[b.client]||null);var c=this.controls=[];_.tb(_.kf,function(a,b){c[b]=new _.Zc});this.j=!0;this.b=a;this.m=!1;this.__gm.ac=b&&b.ac||new _.$c;this.set("standAlone",!0);this.setPov(new _.dd(0,0,1));b&&b.Qe&&(a=b.Qe,_.F(a.zoom)||(a.zoom=_.Fa(b.zoom)?b.zoom:1));this.setValues(b);void 0==this.getVisible()&&this.setVisible(!0);_.M.addListenerOnce(this,"pano_changed",_.Gb(function(){_.S("marker",(0,_.v)(function(a){a.b(this.__gm.ac,
|
||||
this)},this))}))};mf=function(){this.l=[];this.j=this.b=this.f=null};nf=function(a,b,c,d,e){this.$=b;this.b=e;this.f=_.jd(new _.cd([]));this.H=new _.$c;new _.Zc;this.l=new _.$c;this.A=new _.$c;this.m=new _.$c;var f=this.ac=new _.$c;f.b=function(){delete f.b;_.S("marker",_.Gb(function(b){b.b(f,a)}))};this.B=new lf(c,{visible:!1,enableCloseButton:!0,ac:f});this.B.bindTo("reportErrorControl",a);this.B.j=!1;this.j=new mf;this.overlayLayer=null};_.of=function(){this.P=new Pc};
|
||||
_.pf=function(a){this.rk=a||0;_.M.bind(this,"forceredraw",this,this.B)};_.qf=function(a,b){a=a.style;a.width=b.width+b.f;a.height=b.height+b.b};_.rf=function(a){return new _.J(a.offsetWidth,a.offsetHeight)};_.tf=function(){var a=[],b=_.C.google&&_.C.google.maps&&_.C.google.maps.fisfetsz;b&&Array.isArray(b)&&_.sf[15]&&b.forEach(function(b){_.F(b)&&a.push(b)});0==a.length&&(_.sf[35]?a.push(4111425):_.sf[43]||a.push(1301875));return a};uf=function(a){this.data=a||[]};vf=function(a){this.data=a||[]};
|
||||
wf=function(a){this.data=a||[]};xf=function(a){this.data=a||[]};yf=function(a){this.data=a||[]};Ef=function(a){if(!zf){var b=zf={C:"meummm"};if(!Af){var c=Af={C:"ebb5ss8MmbbbEIb100b"};Bf||(Bf={C:"eedmbddemd",G:["uuuu","uuuu"]});c.G=[Bf,"Eb"]}c=Af;Cf||(Cf={C:"10m12m",G:["bb","b"]});b.G=["ii","uue",c,Cf]}return _.Df.b(a.data,zf)};
|
||||
Ff=function(a,b,c,d){_.pf.call(this);this.H=b;this.D=new _.ff;this.I=c+"/maps/api/js/StaticMapService.GetMapImage";this.f=this.b=null;var e;d?e=new id(null,void 0):e=null;this.j=e;this.l=null;this.m=!1;this.set("div",a);this.set("loading",!0)};Mf=function(a){var b=a.get("tilt")||_.E(a.get("styles"));a=a.get("mapTypeId");return b?null:Lf[a]};_.Nf=function(a){a.parentNode&&a.parentNode.removeChild(a)};
|
||||
Of=function(a,b){var c=a.f;c.onload=null;c.onerror=null;var d=a.get("size");d&&(b&&(c.parentNode||a.b.appendChild(c),a.j||_.qf(c,d)),a.set("loading",!1))};
|
||||
Pf=function(a,b,c,d,e){var f=new yf,g=new wf(_.R(f,0));g.data[0]=b.O;g.data[1]=b.R;f.data[1]=e;f.setZoom(c);c=new xf(_.R(f,3));c.data[0]=b.T-b.O;c.data[1]=b.V-b.R;var h=new vf(_.R(f,4));h.data[0]=d;h.data[4]=_.$e(_.U(_.T));h.data[5]=_.af(_.U(_.T)).toLowerCase();h.data[9]=!0;_.tf().forEach(function(a){0>_.vd(h,13).indexOf(a)&&_.wd(h,13,a)});h.data[11]=!0;_.sf[13]&&(b=new uf(_.yd(h,7)),b.data[0]=33,b.data[1]=3,b.data[7]=1);f=a.I+(0,window.unescape)("%3F")+Ef(f);return a.H(f)};
|
||||
Qf=function(a,b){var c=a.f;b!=c.src?(a.j||_.Nf(c),c.onload=function(){Of(a,!0)},c.onerror=function(){Of(a,!1)},c.src=b):!c.parentNode&&b&&a.b.appendChild(c)};_.Sf=function(a){for(var b;b=a.firstChild;)_.Rf(b),a.removeChild(b)};_.Rf=function(a){a=new Ve(a);try{for(;;){var b=a.next();b&&_.M.clearInstanceListeners(b)}}catch(c){if(c!==Tf)throw c;}};
|
||||
Wf=function(a,b){_.Ra();var c=new _.of,d=b||{};d.noClear||_.Sf(a);var e="undefined"==typeof window.document?null:window.document.createElement("div");e&&a.appendChild&&(a.appendChild(e),e.style.width=e.style.height="100%");if(![].forEach)throw _.S("controls",function(b){b.Gg(a)}),Error("The Google Maps API does not support this browser.");_.S("util",function(b){_.Uc(b.b.b,function(b){2==b&&_.S("controls",function(b){b.Ei(a)})})});var f;b=new window.Promise(function(a){f=a});_.Bd.call(this,new nf(this,
|
||||
a,e,c,b));_.q(d.mapTypeId)||(d.mapTypeId="roadmap");this.setValues(d);this.ja=_.sf[15]&&d.noControlsOrLogging;this.mapTypes=new Ad;this.features=new _.N;_.ze(e);this.notify("streetView");b=_.rf(e);var g=null;Uf(d.useStaticMap,b)&&(g=new Ff(e,_.Vf,_.Q(_.U(_.T),9),!0),g.set("size",b),g.bindTo("center",this),g.bindTo("zoom",this),g.bindTo("mapTypeId",this),g.bindTo("styles",this));this.overlayMapTypes=new _.Zc;var h=this.controls=[];_.tb(_.kf,function(a,b){h[b]=new _.Zc});var k=this,n=!0;_.S("map",function(a){k.getDiv()&&
|
||||
e&&a.f(k,d,e,g,n,c,f)});n=!1;this.data=new ne({map:this})};Uf=function(a,b){if(!_.T||2==_.ud(_.T,37))return!1;if(_.q(a))return!!a;a=b.width;b=b.height;return 384E3>=a*b&&800>=a&&800>=b};Zf=function(){_.S("maxzoom",_.Ga)};$f=function(a,b){!a||_.Db(a)||_.F(a)?(this.set("tableId",a),this.setValues(b)):this.setValues(a)};_.ag=_.l();bg=function(a){a=a||{};a.visible=_.Ab(a.visible,!0);return a};_.cg=function(a){return a&&a.radius||6378137};eg=function(a){return a instanceof _.Zc?dg(a):new _.Zc((0,_.be)(a))};
|
||||
gg=function(a){if(_.Ia(a)||a instanceof _.Zc)if(0==_.E(a))var b=!0;else b=a instanceof _.Zc?a.getAt(0):a[0],b=_.Ia(b)||b instanceof _.Zc;else b=!1;return b?a instanceof _.Zc?fg(dg)(a):new _.Zc(_.Qb(eg)(a)):new _.Zc([eg(a)])};fg=function(a){return function(b){if(!(b instanceof _.Zc))throw _.Kb("not an MVCArray");b.forEach(function(b,d){try{a(b)}catch(e){throw _.Kb("at index "+d,e);}});return b}};_.hg=function(a){this.setValues(bg(a));_.S("poly",_.Ga)};
|
||||
ig=function(a){this.set("latLngs",new _.Zc([new _.Zc]));this.setValues(bg(a));_.S("poly",_.Ga)};_.jg=function(a){ig.call(this,a)};_.kg=function(a){ig.call(this,a)};_.lg=function(a){this.setValues(bg(a));_.S("poly",_.Ga)};mg=function(){this.b=null};_.ng=function(){this.b=null};
|
||||
_.pg=function(a){var b=this;this.tileSize=a.tileSize||new _.J(256,256);this.name=a.name;this.alt=a.alt;this.minZoom=a.minZoom;this.maxZoom=a.maxZoom;this.j=(0,_.v)(a.getTileUrl,a);this.b=new _.$c;this.f=null;this.set("opacity",a.opacity);_.S("map",function(a){var c=b.f=a.b,e=b.tileSize||new _.J(256,256);b.b.forEach(function(a){var d=a.__gmimt,f=d.ia,k=d.zoom,n=b.j(f,k);(d.cb=c({M:f.x,N:f.y,ca:k},e,a,n,function(){return _.M.trigger(a,"load")})).setOpacity(og(b))})})};
|
||||
og=function(a){a=a.get("opacity");return"number"==typeof a?a:1};_.qg=function(){_.qg.vf(this,"constructor")};_.rg=function(a,b){_.rg.vf(this,"constructor");this.set("styles",a);a=b||{};this.b=a.baseMapTypeId||"roadmap";this.minZoom=a.minZoom;this.maxZoom=a.maxZoom||20;this.name=a.name;this.alt=a.alt;this.projection=null;this.tileSize=new _.J(256,256)};_.sg=function(a,b){_.Rb(Nb,"container is not a Node")(a);this.setValues(b);_.S("controls",(0,_.v)(function(b){b.Yl(this,a)},this))};tg=_.oa("b");
|
||||
ug=function(a,b,c){for(var d=Array(b.length),e=0,f=b.length;e<f;++e)d[e]=b.charCodeAt(e);d.unshift(c);a=a.b;c=b=0;for(e=d.length;c<e;++c)b*=1729,b+=d[c],b%=a;return b};xg=function(){var a=_.P(new Ye(_.T.data[4]),0),b=new tg(131071),c=(0,window.unescape)("%26%74%6F%6B%65%6E%3D");return function(d){d=d.replace(vg,"%27");var e=d+c;wg||(wg=/(?:https?:\/\/[^/]+)?(.*)/);d=wg.exec(d);return e+ug(b,d&&d[1],a)}};yg=function(){var a=new tg(2147483647);return function(b){return ug(a,b,0)}};
|
||||
zg=function(a){for(var b=a.split("."),c=window,d=window,e=0;e<b.length;e++)if(d=c,c=c[b[e]],!c)throw _.Kb(a+" is not a function");return function(){c.apply(d)}};Ag=function(){for(var a in Object.prototype)window.console&&window.console.error("This site adds property <"+a+"> to Object.prototype. Extending Object.prototype breaks JavaScript for..in loops, which are used heavily in Google Maps API v3.")};
|
||||
Bg=function(a){(a="version"in a)&&window.console&&window.console.error("You have included the Google Maps API multiple times on this page. This may cause unexpected errors.");return a};_.ra=[];_.ua="undefined"!=typeof window&&window===this?this:"undefined"!=typeof window.global&&null!=window.global?window.global:this;_.Cg="function"==typeof Object.create?Object.create:function(a){function b(){}b.prototype=a;return new b};
|
||||
if("function"==typeof Object.setPrototypeOf)Dg=Object.setPrototypeOf;else{var Eg;a:{var Gg={qk:!0},Hg={};try{Hg.__proto__=Gg;Eg=Hg.qk;break a}catch(a){}Eg=!1}Dg=Eg?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null}_.Ig=Dg;wa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};va=function(){var a=0;return function(b){return"jscomp_symbol_"+(b||"")+a++}}();
|
||||
Ca("Array.prototype.findIndex",function(a){return a?a:function(a,c){return Ba(this,a,c).Ae}});Ca("Array.prototype.find",function(a){return a?a:function(a,c){return Ba(this,a,c).Si}});Ca("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}});Ca("Array.prototype.includes",function(a){return a?a:function(a,c){var b=this;b instanceof String&&(b=String(b));var e=b.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c<e;c++){var f=b[c];if(f===a||Object.is(f,a))return!0}return!1}});
|
||||
Ca("String.prototype.includes",function(a){return a?a:function(a,c){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(a instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==(this+"").indexOf(a,c||0)}});
|
||||
Ca("Promise",function(a){function b(a){this.f=0;this.j=void 0;this.b=[];var b=this.l();try{a(b.resolve,b.reject)}catch(k){b.reject(k)}}function c(){this.b=null}function d(a){return a instanceof b?a:new b(function(b){b(a)})}if(a)return a;c.prototype.f=function(a){null==this.b&&(this.b=[],this.l());this.b.push(a)};c.prototype.l=function(){var a=this;this.j(function(){a.A()})};var e=_.ua.setTimeout;c.prototype.j=function(a){e(a,0)};c.prototype.A=function(){for(;this.b&&this.b.length;){var a=this.b;this.b=
|
||||
[];for(var b=0;b<a.length;++b){var c=a[b];a[b]=null;try{c()}catch(n){this.m(n)}}}this.b=null};c.prototype.m=function(a){this.j(function(){throw a;})};b.prototype.l=function(){function a(a){return function(d){c||(c=!0,a.call(b,d))}}var b=this,c=!1;return{resolve:a(this.I),reject:a(this.m)}};b.prototype.I=function(a){if(a===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(a instanceof b)this.Z(a);else{a:switch(typeof a){case "object":var c=null!=a;break a;case "function":c=!0;
|
||||
break a;default:c=!1}c?this.H(a):this.A(a)}};b.prototype.H=function(a){var b=void 0;try{b=a.then}catch(k){this.m(k);return}"function"==typeof b?this.na(b,a):this.A(a)};b.prototype.m=function(a){this.B(2,a)};b.prototype.A=function(a){this.B(1,a)};b.prototype.B=function(a,b){if(0!=this.f)throw Error("Cannot settle("+a+", "+b+"): Promise already settled in state"+this.f);this.f=a;this.j=b;this.D()};b.prototype.D=function(){if(null!=this.b){for(var a=0;a<this.b.length;++a)f.f(this.b[a]);this.b=null}};
|
||||
var f=new c;b.prototype.Z=function(a){var b=this.l();a.me(b.resolve,b.reject)};b.prototype.na=function(a,b){var c=this.l();try{a.call(b,c.resolve,c.reject)}catch(n){c.reject(n)}};b.prototype.then=function(a,c){function d(a,b){return"function"==typeof a?function(b){try{e(a(b))}catch(w){f(w)}}:b}var e,f,g=new b(function(a,b){e=a;f=b});this.me(d(a,e),d(c,f));return g};b.prototype["catch"]=function(a){return this.then(void 0,a)};b.prototype.me=function(a,b){function c(){switch(d.f){case 1:a(d.j);break;
|
||||
case 2:b(d.j);break;default:throw Error("Unexpected state: "+d.f);}}var d=this;null==this.b?f.f(c):this.b.push(c)};b.resolve=d;b.reject=function(a){return new b(function(b,c){c(a)})};b.race=function(a){return new b(function(b,c){for(var e=_.Aa(a),f=e.next();!f.done;f=e.next())d(f.value).me(b,c)})};b.all=function(a){var c=_.Aa(a),e=c.next();return e.done?d([]):new b(function(a,b){function f(b){return function(c){g[b]=c;h--;0==h&&a(g)}}var g=[],h=0;do g.push(void 0),h++,d(e.value).me(f(g.length-1),
|
||||
b),e=c.next();while(!e.done)})};return b});Ca("Array.from",function(a){return a?a:function(a,c,d){(0,_.ya)();c=null!=c?c:_.na();var b=[],f=a[window.Symbol.iterator];if("function"==typeof f)for(a=f.call(a);!(f=a.next()).done;)b.push(c.call(d,f.value));else{f=a.length;for(var g=0;g<f;g++)b.push(c.call(d,a[g]))}return b}});Ca("Math.sign",function(a){return a?a:function(a){a=Number(a);return 0===a||(0,window.isNaN)(a)?a:0<a?1:-1}});
|
||||
Ca("WeakMap",function(a){function b(a){this.b=(f+=Math.random()+1).toString();if(a){ta();(0,_.ya)();a=_.Aa(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}}function c(a){Da(a,e)||wa(a,e,{value:{}})}function d(a){var b=Object[a];b&&(Object[a]=function(a){c(a);return b(a)})}if(function(){if(!a||!Object.seal)return!1;try{var b=Object.seal({}),c=Object.seal({}),d=new a([[b,2],[c,3]]);if(2!=d.get(b)||3!=d.get(c))return!1;d["delete"](b);d.set(c,4);return!d.has(b)&&4==d.get(c)}catch(n){return!1}}())return a;
|
||||
var e="$jscomp_hidden_"+Math.random();d("freeze");d("preventExtensions");d("seal");var f=0;b.prototype.set=function(a,b){c(a);if(!Da(a,e))throw Error("WeakMap key fail: "+a);a[e][this.b]=b;return this};b.prototype.get=function(a){return Da(a,e)?a[e][this.b]:void 0};b.prototype.has=function(a){return Da(a,e)&&Da(a[e],this.b)};b.prototype["delete"]=function(a){return Da(a,e)&&Da(a[e],this.b)?delete a[e][this.b]:!1};return b});
|
||||
Ca("Map",function(a){function b(){var a={};return a.Vb=a.next=a.head=a}function c(a,b){var c=a.b;return za(function(){if(c){for(;c.head!=a.b;)c=c.Vb;for(;c.next!=c.head;)return c=c.next,{done:!1,value:b(c)};c=null}return{done:!0,value:void 0}})}function d(a,b){var c=b&&typeof b;"object"==c||"function"==c?f.has(b)?c=f.get(b):(c=""+ ++g,f.set(b,c)):c="p_"+b;var d=a.f[c];if(d&&Da(a.f,c))for(a=0;a<d.length;a++){var e=d[a];if(b!==b&&e.key!==e.key||b===e.key)return{id:c,list:d,index:a,Za:e}}return{id:c,
|
||||
list:d,index:-1,Za:void 0}}function e(a){this.f={};this.b=b();this.size=0;if(a){a=_.Aa(a);for(var c;!(c=a.next()).done;)c=c.value,this.set(c[0],c[1])}}if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var b=Object.seal({x:4}),c=new a(_.Aa([[b,"s"]]));if("s"!=c.get(b)||1!=c.size||c.get({x:4})||c.set({x:4},"t")!=c||2!=c.size)return!1;var d=c.entries(),e=d.next();if(e.done||e.value[0]!=b||"s"!=e.value[1])return!1;e=d.next();return e.done||4!=
|
||||
e.value[0].x||"t"!=e.value[1]||!d.next().done?!1:!0}catch(r){return!1}}())return a;ta();(0,_.ya)();var f=new window.WeakMap;e.prototype.set=function(a,b){var c=d(this,a);c.list||(c.list=this.f[c.id]=[]);c.Za?c.Za.value=b:(c.Za={next:this.b,Vb:this.b.Vb,head:this.b,key:a,value:b},c.list.push(c.Za),this.b.Vb.next=c.Za,this.b.Vb=c.Za,this.size++);return this};e.prototype["delete"]=function(a){a=d(this,a);return a.Za&&a.list?(a.list.splice(a.index,1),a.list.length||delete this.f[a.id],a.Za.Vb.next=a.Za.next,
|
||||
a.Za.next.Vb=a.Za.Vb,a.Za.head=null,this.size--,!0):!1};e.prototype.clear=function(){this.f={};this.b=this.b.Vb=b();this.size=0};e.prototype.has=function(a){return!!d(this,a).Za};e.prototype.get=function(a){return(a=d(this,a).Za)&&a.value};e.prototype.entries=function(){return c(this,function(a){return[a.key,a.value]})};e.prototype.keys=function(){return c(this,function(a){return a.key})};e.prototype.values=function(){return c(this,function(a){return a.value})};e.prototype.forEach=function(a,b){for(var c=
|
||||
this.entries(),d;!(d=c.next()).done;)d=d.value,a.call(b,d[1],d[0],this)};e.prototype[window.Symbol.iterator]=e.prototype.entries;var g=0;return e});Ca("Array.prototype.fill",function(a){return a?a:function(a,c,d){var b=this.length||0;0>c&&(c=Math.max(0,b+c));if(null==d||d>b)d=b;d=Number(d);0>d&&(d=Math.max(0,b+d));for(c=Number(c||0);c<d;c++)this[c]=a;return this}});
|
||||
Ca("Set",function(a){function b(a){this.F=new window.Map;if(a){a=_.Aa(a);for(var b;!(b=a.next()).done;)this.add(b.value)}this.size=this.F.size}if(function(){if(!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var b=Object.seal({x:4}),d=new a(_.Aa([b]));if(!d.has(b)||1!=d.size||d.add(b)!=d||1!=d.size||d.add({x:4})!=d||2!=d.size)return!1;var e=d.entries(),f=e.next();if(f.done||f.value[0]!=b||f.value[1]!=b)return!1;f=e.next();return f.done||f.value[0]==b||4!=
|
||||
f.value[0].x||f.value[1]!=f.value[0]?!1:e.next().done}catch(g){return!1}}())return a;ta();(0,_.ya)();b.prototype.add=function(a){this.F.set(a,a);this.size=this.F.size;return this};b.prototype["delete"]=function(a){a=this.F["delete"](a);this.size=this.F.size;return a};b.prototype.clear=function(){this.F.clear();this.size=0};b.prototype.has=function(a){return this.F.has(a)};b.prototype.entries=function(){return this.F.entries()};b.prototype.values=function(){return this.F.values()};b.prototype.keys=
|
||||
b.prototype.values;b.prototype[window.Symbol.iterator]=b.prototype.values;b.prototype.forEach=function(a,b){var c=this;this.F.forEach(function(d){return a.call(b,d,d,c)})};return b});_.C=this;Ma="closure_uid_"+(1E9*Math.random()>>>0);Na=0;a:{var Jg=_.C.navigator;if(Jg){var Kg=Jg.userAgent;if(Kg){_.Ya=Kg;break a}}_.Ya=""};_.fb[" "]=_.Ga;var Yg;_.Lg=_.$a("Opera");_.Mg=_.ab();_.Ng=_.$a("Edge");_.Og=_.$a("Gecko")&&!(_.Za()&&!_.$a("Edge"))&&!(_.$a("Trident")||_.$a("MSIE"))&&!_.$a("Edge");_.Pg=_.Za()&&!_.$a("Edge");_.Qg=_.$a("Macintosh");_.Rg=_.$a("Windows");_.Sg=_.$a("Linux")||_.$a("CrOS");_.Tg=_.$a("Android");_.Vg=_.eb();_.Wg=_.$a("iPad");_.Xg=_.$a("iPod");
|
||||
a:{var Zg="",$g=function(){var a=_.Ya;if(_.Og)return/rv:([^\);]+)(\)|;)/.exec(a);if(_.Ng)return/Edge\/([\d\.]+)/.exec(a);if(_.Mg)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(_.Pg)return/WebKit\/(\S+)/.exec(a);if(_.Lg)return/(?:Version)[ \/]?(\S+)/.exec(a)}();$g&&(Zg=$g?$g[1]:"");if(_.Mg){var ah=gb();if(null!=ah&&ah>(0,window.parseFloat)(Zg)){Yg=String(ah);break a}}Yg=Zg}_.bh=Yg;var dh=_.C.document;_.ch=dh&&_.Mg?gb()||("CSS1Compat"==dh.compatMode?(0,window.parseInt)(_.bh,10):5):void 0;_.eh=_.$a("Firefox");_.fh=_.eb()||_.$a("iPod");_.gh=_.$a("iPad");_.hh=_.db();_.ih=bb();_.jh=_.cb()&&!(_.eb()||_.$a("iPad")||_.$a("iPod"));var kh;kh=_.Og||_.Pg&&!_.jh||_.Lg;_.lh=kh||"function"==typeof _.C.btoa;_.mh=kh||!_.jh&&!_.Mg&&"function"==typeof _.C.atob;hb.prototype.get=function(){if(0<this.f){this.f--;var a=this.b;this.b=a.next;a.next=null}else a=this.j();return a};var nh=function(a){return function(){return a}}(null);var mb,lb=_.ib;var oh=new hb(function(){return new qb},function(a){a.reset()});pb.prototype.add=function(a,b){var c=oh.get();c.set(a,b);this.f?this.f.next=c:this.b=c;this.f=c};pb.prototype.remove=function(){var a=null;this.b&&(a=this.b,this.b=this.b.next,this.b||(this.f=null),a.next=null);return a};qb.prototype.set=function(a,b){this.Zc=a;this.b=b;this.next=null};qb.prototype.reset=function(){this.next=this.b=this.Zc=null};_.kb.m=function(){if(_.C.Promise&&_.C.Promise.resolve){var a=_.C.Promise.resolve(void 0);_.kb.b=function(){a.then(_.kb.f)}}else _.kb.b=function(){ob()}};_.kb.A=function(a){_.kb.b=function(){ob();a&&a(_.kb.f)}};_.kb.j=!1;_.kb.l=new pb;_.kb.f=function(){for(var a;a=_.kb.l.remove();){try{a.Zc.call(a.b)}catch(c){jb(c)}var b=oh;b.l(a);100>b.f&&(b.f++,a.next=b.b,b.b=a)}_.kb.j=!1};_.ph={ROADMAP:"roadmap",SATELLITE:"satellite",HYBRID:"hybrid",TERRAIN:"terrain"};_.kf={TOP_LEFT:1,TOP_CENTER:2,TOP:2,TOP_RIGHT:3,LEFT_CENTER:4,LEFT_TOP:5,LEFT:5,LEFT_BOTTOM:6,RIGHT_TOP:7,RIGHT:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM:11,BOTTOM_RIGHT:12,CENTER:13};_.z(Jb,Error);var qh,sh;_.Wb=_.Rb(_.F,"not a number");qh=_.Tb(_.Wb,function(a){if((0,window.isNaN)(a))throw _.Kb("NaN is not an accepted value");return a});_.rh=_.Rb(_.Db,"not a string");sh=_.Rb(_.Eb,"not a boolean");_.th=_.G(_.Wb);_.uh=_.G(_.rh);_.vh=_.G(sh);_.wh=new _.H(0,0);_.H.prototype.toString=function(){return"("+this.x+", "+this.y+")"};_.H.prototype.da=function(a){return a?a.x==this.x&&a.y==this.y:!1};_.H.prototype.equals=_.H.prototype.da;_.H.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y)};_.H.prototype.He=_.sa(0);_.xh=new _.J(0,0);_.J.prototype.toString=function(){return"("+this.width+", "+this.height+")"};_.J.prototype.da=function(a){return a?a.width==this.width&&a.height==this.height:!1};_.J.prototype.equals=_.J.prototype.da;_.Zb.prototype.da=function(a){return a?this.J==a.J&&this.K==a.K:!1};_.yh=new _.ac({Mc:new _.$b(256),Nc:void 0});_.bc.prototype.da=function(a){return a?this.m11==a.m11&&this.m12==a.m12&&this.m21==a.m21&&this.m22==a.m22:!1};_.fc.prototype.isEmpty=function(){return!(this.O<this.T&&this.R<this.V)};_.fc.prototype.extend=function(a){a&&(this.O=Math.min(this.O,a.x),this.T=Math.max(this.T,a.x),this.R=Math.min(this.R,a.y),this.V=Math.max(this.V,a.y))};_.fc.prototype.getCenter=function(){return new _.H((this.O+this.T)/2,(this.R+this.V)/2)};_.fc.prototype.da=function(a){return a?this.O==a.O&&this.R==a.R&&this.T==a.T&&this.V==a.V:!1};_.zh=_.gc(-window.Infinity,-window.Infinity,window.Infinity,window.Infinity);_.gc(0,0,0,0);_.m=hc.prototype;_.m.isEmpty=function(){return 360==this.b-this.f};_.m.intersects=function(a){var b=this.b,c=this.f;return this.isEmpty()||a.isEmpty()?!1:_.ic(this)?_.ic(a)||a.b<=this.f||a.f>=b:_.ic(a)?a.b<=c||a.f>=b:a.b<=c&&a.f>=b};_.m.contains=function(a){-180==a&&(a=180);var b=this.b,c=this.f;return _.ic(this)?(a>=b||a<=c)&&!this.isEmpty():a>=b&&a<=c};_.m.extend=function(a){this.contains(a)||(this.isEmpty()?this.b=this.f=a:_.jc(a,this.b)<_.jc(this.f,a)?this.b=a:this.f=a)};
|
||||
_.m.da=function(a){return 1E-9>=Math.abs(a.b-this.b)%360+Math.abs(_.kc(a)-_.kc(this))};_.m.X=function(){var a=(this.b+this.f)/2;_.ic(this)&&(a=_.wb(a+180,-180,180));return a};_.m=lc.prototype;_.m.isEmpty=function(){return this.b>this.f};_.m.intersects=function(a){var b=this.b,c=this.f;return b<=a.b?a.b<=c&&a.b<=a.f:b<=a.f&&b<=c};_.m.contains=function(a){return a>=this.b&&a<=this.f};_.m.extend=function(a){this.isEmpty()?this.f=this.b=a:a<this.b?this.b=a:a>this.f&&(this.f=a)};
|
||||
_.m.da=function(a){return this.isEmpty()?a.isEmpty():1E-9>=Math.abs(a.b-this.b)+Math.abs(this.f-a.f)};_.m.X=function(){return(this.f+this.b)/2};var mc=_.Mb({lat:_.Wb,lng:_.Wb},!0);_.K.prototype.toString=function(){return"("+this.lat()+", "+this.lng()+")"};_.K.prototype.toJSON=function(){return{lat:this.lat(),lng:this.lng()}};_.K.prototype.da=function(a){return a?_.xb(this.lat(),a.lat())&&_.xb(this.lng(),a.lng()):!1};_.K.prototype.equals=_.K.prototype.da;_.K.prototype.toUrlValue=function(a){a=_.q(a)?a:6;return pc(this.lat(),a)+","+pc(this.lng(),a)};_.be=_.Qb(_.qc);_.m=_.rc.prototype;_.m.getCenter=function(){return new _.K(this.f.X(),this.b.X())};_.m.toString=function(){return"("+this.getSouthWest()+", "+this.getNorthEast()+")"};_.m.toJSON=function(){return{south:this.f.b,west:this.b.b,north:this.f.f,east:this.b.f}};_.m.toUrlValue=function(a){var b=this.getSouthWest(),c=this.getNorthEast();return[b.toUrlValue(a),c.toUrlValue(a)].join()};_.m.da=function(a){if(!a)return!1;a=_.uc(a);return this.f.da(a.f)&&this.b.da(a.b)};_.rc.prototype.equals=_.rc.prototype.da;
|
||||
_.m=_.rc.prototype;_.m.contains=function(a){a=_.qc(a);return this.f.contains(a.lat())&&this.b.contains(a.lng())};_.m.intersects=function(a){a=_.uc(a);return this.f.intersects(a.f)&&this.b.intersects(a.b)};_.m.extend=function(a){a=_.qc(a);this.f.extend(a.lat());this.b.extend(a.lng());return this};_.m.union=function(a){a=_.uc(a);if(!a||a.isEmpty())return this;this.extend(a.getSouthWest());this.extend(a.getNorthEast());return this};_.m.getSouthWest=function(){return new _.K(this.f.b,this.b.b,!0)};
|
||||
_.m.getNorthEast=function(){return new _.K(this.f.f,this.b.f,!0)};_.m.toSpan=function(){var a=this.f;a=a.isEmpty()?0:a.f-a.b;return new _.K(a,_.kc(this.b),!0)};_.m.isEmpty=function(){return this.f.isEmpty()||this.b.isEmpty()};var tc=_.Mb({south:_.Wb,west:_.Wb,north:_.Wb,east:_.Wb},!1);var Gc;
|
||||
_.M={addListener:function(a,b,c){return new Hc(a,b,c,0)},hasListeners:function(a,b){if(!a)return!1;b=(a=a.__e3_)&&a[b];if(a=!!b){a:{for(c in b){var c=!1;break a}c=!0}a=!c}return a},removeListener:function(a){a&&a.remove()},clearListeners:function(a,b){_.tb(Dc(a,b),function(a,b){b&&b.remove()})},clearInstanceListeners:function(a){_.tb(Dc(a),function(a,c){c&&c.remove()})},trigger:function(a,b,c){if(_.M.hasListeners(a,b)){var d=_.Xa(arguments,2),e=Dc(a,b),f;for(f in e){var g=e[f];g&&g.b.apply(g.f,d)}}},
|
||||
addDomListener:function(a,b,c,d){var e=d?4:1;if(!a.addEventListener&&a.attachEvent)return c=new Hc(a,b,c,2),a.attachEvent("on"+b,Ic(c)),c;a.addEventListener&&a.addEventListener(b,c,d);return new Hc(a,b,c,e)},addDomListenerOnce:function(a,b,c,d){var e=_.M.addDomListener(a,b,function(){e.remove();return c.apply(this,arguments)},d);return e},ma:function(a,b,c,d){return _.M.addDomListener(a,b,Ec(c,d))},bind:function(a,b,c,d){return _.M.addListener(a,b,(0,_.v)(d,c))},addListenerOnce:function(a,b,c){var d=
|
||||
_.M.addListener(a,b,function(){d.remove();return c.apply(this,arguments)});return d},forward:function(a,b,c){return _.M.addListener(a,b,Fc(b,c))},ad:function(a,b,c,d){_.M.addDomListener(a,b,Fc(b,c,!d))}};Gc=0;Hc.prototype.remove=function(){if(this.f){if(this.f.removeEventListener)switch(this.l){case 1:this.f.removeEventListener(this.j,this.b,!1);break;case 4:this.f.removeEventListener(this.j,this.b,!0)}delete Cc(this.f,this.j)[this.id];this.b=this.f=null}};_.m=_.N.prototype;_.m.get=function(a){var b=Oc(this);a+="";b=Hb(b,a);if(_.q(b)){if(b){a=b.Cb;b=b.gd;var c="get"+_.Nc(a);return b[c]?b[c]():b.get(a)}return this[a]}};_.m.set=function(a,b){var c=Oc(this);a+="";var d=Hb(c,a);if(d)if(a=d.Cb,d=d.gd,c="set"+_.Nc(a),d[c])d[c](b);else d.set(a,b);else this[a]=b,c[a]=null,Lc(this,a)};_.m.notify=function(a){var b=Oc(this);a+="";(b=Hb(b,a))?b.gd.notify(b.Cb):Lc(this,a)};
|
||||
_.m.setValues=function(a){for(var b in a){var c=a[b],d="set"+_.Nc(b);if(this[d])this[d](c);else this.set(b,c)}};_.m.setOptions=_.N.prototype.setValues;_.m.changed=_.l();var Mc={};_.N.prototype.bindTo=function(a,b,c,d){a+="";c=(c||a)+"";this.unbind(a);var e={gd:this,Cb:a},f={gd:b,Cb:c,jh:e};Oc(this)[a]=f;Kc(b,c)[_.Jc(e)]=e;d||Lc(this,a)};_.N.prototype.unbind=function(a){var b=Oc(this),c=b[a];c&&(c.jh&&delete Kc(c.gd,c.Cb)[_.Jc(c.jh)],this[a]=this.get(a),b[a]=null)};
|
||||
_.N.prototype.unbindAll=function(){var a=(0,_.v)(this.unbind,this),b=Oc(this),c;for(c in b)a(c)};_.N.prototype.addListener=function(a,b){return _.M.addListener(this,a,b)};Pc.prototype.addListener=function(a,b,c){c=c?{kh:!1}:null;var d=!this.P.length,e=this.P.find(Sc(a,b));e?e.once=e.once&&c:this.P.push({Zc:a,context:b||null,once:c});d&&this.f();return a};Pc.prototype.addListenerOnce=function(a,b){this.addListener(a,b,!0);return a};Pc.prototype.removeListener=function(a,b){if(this.P.length){var c=this.P;a=_.Ta(c,Sc(a,b),void 0);0<=a&&_.Ua(c,a);this.P.length||this.b()}};var Qc=_.kb;_.m=_.Tc.prototype;_.m.Pd=_.l();_.m.Od=_.l();_.m.addListener=function(a,b){return this.P.addListener(a,b)};_.m.addListenerOnce=function(a,b){return this.P.addListenerOnce(a,b)};_.m.removeListener=function(a,b){return this.P.removeListener(a,b)};_.m.notify=function(a){_.Rc(this.P,function(a){a(this.get())},this,a)};_.z(_.Zc,_.N);_.m=_.Zc.prototype;_.m.getAt=function(a){return this.b[a]};_.m.indexOf=function(a){for(var b=0,c=this.b.length;b<c;++b)if(a===this.b[b])return b;return-1};_.m.forEach=function(a){for(var b=0,c=this.b.length;b<c;++b)a(this.b[b],b)};_.m.setAt=function(a,b){var c=this.b[a],d=this.b.length;if(a<d)this.b[a]=b,_.M.trigger(this,"set_at",a,c),this.l&&this.l(a,c);else{for(c=d;c<a;++c)this.insertAt(c,void 0);this.insertAt(a,b)}};
|
||||
_.m.insertAt=function(a,b){this.b.splice(a,0,b);Yc(this);_.M.trigger(this,"insert_at",a);this.f&&this.f(a)};_.m.removeAt=function(a){var b=this.b[a];this.b.splice(a,1);Yc(this);_.M.trigger(this,"remove_at",a,b);this.j&&this.j(a,b);return b};_.m.push=function(a){this.insertAt(this.b.length,a);return this.b.length};_.m.pop=function(){return this.removeAt(this.b.length-1)};_.m.getArray=_.pa("b");_.m.clear=function(){for(;this.get("length");)this.pop()};_.Xc(_.Zc.prototype,{length:null});_.$c.prototype.remove=function(a){var b=this.f,c=_.Jc(a);b[c]&&(delete b[c],--this.j,_.M.trigger(this,"remove",a),this.onRemove&&this.onRemove(a))};_.$c.prototype.contains=function(a){return!!this.f[_.Jc(a)]};_.$c.prototype.forEach=function(a){var b=this.f,c;for(c in b)a.call(this,b[c])};_.cd.prototype.ub=_.sa(1);_.cd.prototype.forEach=function(a,b){_.A(this.b,function(c,d){a.call(b,c,d)})};var Ah=_.Mb({zoom:_.G(qh),heading:qh,pitch:qh});_.z(_.gd,_.N);_.z(_.hd,_.Tc);_.hd.prototype.set=function(a){this.m&&this.get()===a||(this.Ci(a),this.notify())};_.z(id,_.hd);id.prototype.get=_.pa("b");id.prototype.Ci=_.oa("b");_.z(kd,_.N);_.od.prototype.forEach=function(a){for(var b=1+this.Qb,c=0,d={type:"s",Nd:0,Zd:null,Vd:!1,Tf:!1},e=this.b.length;b<e;){d.Tf=!1;var f=this.b.substr(b).match(/^(\d+)/);f?(b+=f[1].length,d.Nd=(0,window.parseInt)(f,10)):d.Nd++;f=this.b[b++];var g=f.toLowerCase();d.Vd=g!=f;g in Bh?(d.type=Bh[g],d.Tf="B"!=d.type):d.type=g;"m"==d.type?d.Zd=this.f[c++]:d.Zd=null;a(d)}};var Bh={a:"B",k:"j",p:"o",w:"v",q:"y",r:"h"};var Ch;_.Df=new pd;Ch=/'/g;pd.prototype.b=function(a,b){var c=[];rd(a,b,c);return c.join("&").replace(Ch,"%27")};_.O.prototype.da=function(a){return _.nd(this.data,a?(a&&a).data:null)};_.O.prototype.Ki=_.sa(2);_.z(Ad,_.N);Ad.prototype.set=function(a,b){if(null!=b&&!(b&&_.F(b.maxZoom)&&b.tileSize&&b.tileSize.width&&b.tileSize.height&&b.getTile&&b.getTile.apply))throw Error("Expected value implementing google.maps.MapType");return _.N.prototype.set.apply(this,arguments)};_.z(_.Bd,_.N);/*
|
||||
|
||||
Math.uuid.js (v1.4)
|
||||
http://www.broofa.com
|
||||
mailto:robert@broofa.com
|
||||
Copyright (c) 2010 Robert Kieffer
|
||||
Dual licensed under the MIT and GPL licenses.
|
||||
*/
|
||||
var Cd;(function(){var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");Cd=function(){for(var b=Array(36),c=0,d,e=0;36>e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19==e?d&3|8:d]);return b.join("")}})();_.z(_.Fd,Ed);_.Fd.prototype.getType=_.qa("Point");_.Fd.prototype.forEachLatLng=function(a){a(this.b)};_.Fd.prototype.get=_.pa("b");var $d=_.Qb(Gd);Nd.f=void 0;Nd.b=function(){return Nd.f?Nd.f:Nd.f=new Nd};Nd.prototype.xa=function(a,b){if(!this.b[a]){var c=this,d=c.m;Od(c.j,function(e){for(var f=e.b[a]||[],g=e.l[a]||[],h=d[a]=_.Hd(f.length,function(){delete d[a];b(e.f);for(var f=c.f[a],h=f?f.length:0,k=0;k<h;++k)f[k](c.b[a]);delete c.f[a];k=0;for(f=g.length;k<f;++k)h=g[k],d[h]&&d[h]()}),k=0,n=f.length;k<n;++k)c.b[f[k]]&&h()})}};_.m=_.Ud.prototype;_.m.getId=_.pa("j");_.m.getGeometry=_.pa("b");_.m.setGeometry=function(a){var b=this.b;try{this.b=a?Gd(a):null}catch(c){_.Lb(c);return}_.M.trigger(this,"setgeometry",{feature:this,newGeometry:this.b,oldGeometry:b})};_.m.getProperty=function(a){return Hb(this.f,a)};_.m.setProperty=function(a,b){if(void 0===b)this.removeProperty(a);else{var c=this.getProperty(a);this.f[a]=b;_.M.trigger(this,"setproperty",{feature:this,name:a,newValue:b,oldValue:c})}};
|
||||
_.m.removeProperty=function(a){var b=this.getProperty(a);delete this.f[a];_.M.trigger(this,"removeproperty",{feature:this,name:a,oldValue:b})};_.m.forEachProperty=function(a){for(var b in this.f)a(this.getProperty(b),b)};_.m.toGeoJson=function(a){var b=this;_.S("data",function(c){c.f(b,a)})};var Dh={zo:"Point",vo:"LineString",POLYGON:"Polygon"};var Eh={CIRCLE:0,FORWARD_CLOSED_ARROW:1,FORWARD_OPEN_ARROW:2,BACKWARD_CLOSED_ARROW:3,BACKWARD_OPEN_ARROW:4};_.m=Vd.prototype;_.m.contains=function(a){return this.b.hasOwnProperty(_.Jc(a))};_.m.getFeatureById=function(a){return Hb(this.f,a)};
|
||||
_.m.add=function(a){a=a||{};a=a instanceof _.Ud?a:new _.Ud(a);if(!this.contains(a)){var b=a.getId();if(b){var c=this.getFeatureById(b);c&&this.remove(c)}c=_.Jc(a);this.b[c]=a;b&&(this.f[b]=a);var d=_.M.forward(a,"setgeometry",this),e=_.M.forward(a,"setproperty",this),f=_.M.forward(a,"removeproperty",this);this.j[c]=function(){_.M.removeListener(d);_.M.removeListener(e);_.M.removeListener(f)};_.M.trigger(this,"addfeature",{feature:a})}return a};
|
||||
_.m.remove=function(a){var b=_.Jc(a),c=a.getId();if(this.b[b]){delete this.b[b];c&&delete this.f[c];if(c=this.j[b])delete this.j[b],c();_.M.trigger(this,"removefeature",{feature:a})}};_.m.forEach=function(a){for(var b in this.b)a(this.b[b])};_.me="click dblclick mousedown mousemove mouseout mouseover mouseup rightclick".split(" ");Yd.prototype.get=function(a){return this.b[a]};Yd.prototype.set=function(a,b){var c=this.b;c[a]||(c[a]={});_.ub(c[a],b);_.M.trigger(this,"changed",a)};Yd.prototype.reset=function(a){delete this.b[a];_.M.trigger(this,"changed",a)};Yd.prototype.forEach=function(a){_.tb(this.b,a)};_.z(Zd,_.N);Zd.prototype.overrideStyle=function(a,b){this.b.set(_.Jc(a),b)};Zd.prototype.revertStyle=function(a){a?this.b.reset(_.Jc(a)):this.b.forEach((0,_.v)(this.b.reset,this.b))};_.z(_.ae,Ed);_.m=_.ae.prototype;_.m.getType=_.qa("GeometryCollection");_.m.getLength=function(){return this.b.length};_.m.getAt=function(a){return this.b[a]};_.m.getArray=function(){return this.b.slice()};_.m.forEachLatLng=function(a){this.b.forEach(function(b){b.forEachLatLng(a)})};_.z(_.ce,Ed);_.m=_.ce.prototype;_.m.getType=_.qa("LineString");_.m.getLength=function(){return this.b.length};_.m.getAt=function(a){return this.b[a]};_.m.getArray=function(){return this.b.slice()};_.m.forEachLatLng=function(a){this.b.forEach(a)};var ee=_.Qb(_.Ob(_.ce,"google.maps.Data.LineString",!0));_.z(_.de,Ed);_.m=_.de.prototype;_.m.getType=_.qa("LinearRing");_.m.getLength=function(){return this.b.length};_.m.getAt=function(a){return this.b[a]};_.m.getArray=function(){return this.b.slice()};_.m.forEachLatLng=function(a){this.b.forEach(a)};var he=_.Qb(_.Ob(_.de,"google.maps.Data.LinearRing",!0));_.z(_.fe,Ed);_.m=_.fe.prototype;_.m.getType=_.qa("MultiLineString");_.m.getLength=function(){return this.b.length};_.m.getAt=function(a){return this.b[a]};_.m.getArray=function(){return this.b.slice()};_.m.forEachLatLng=function(a){this.b.forEach(function(b){b.forEachLatLng(a)})};_.z(_.ge,Ed);_.m=_.ge.prototype;_.m.getType=_.qa("MultiPoint");_.m.getLength=function(){return this.b.length};_.m.getAt=function(a){return this.b[a]};_.m.getArray=function(){return this.b.slice()};_.m.forEachLatLng=function(a){this.b.forEach(a)};_.z(_.ie,Ed);_.m=_.ie.prototype;_.m.getType=_.qa("Polygon");_.m.getLength=function(){return this.b.length};_.m.getAt=function(a){return this.b[a]};_.m.getArray=function(){return this.b.slice()};_.m.forEachLatLng=function(a){this.b.forEach(function(b){b.forEachLatLng(a)})};var je=_.Qb(_.Ob(_.ie,"google.maps.Data.Polygon",!0));_.z(_.ke,Ed);_.m=_.ke.prototype;_.m.getType=_.qa("MultiPolygon");_.m.getLength=function(){return this.b.length};_.m.getAt=function(a){return this.b[a]};_.m.getArray=function(){return this.b.slice()};_.m.forEachLatLng=function(a){this.b.forEach(function(b){b.forEachLatLng(a)})};_.Fh=_.G(_.Ob(_.Bd,"Map"));_.z(ne,_.N);_.m=ne.prototype;_.m.contains=function(a){return this.b.contains(a)};_.m.getFeatureById=function(a){return this.b.getFeatureById(a)};_.m.add=function(a){return this.b.add(a)};_.m.remove=function(a){this.b.remove(a)};_.m.forEach=function(a){this.b.forEach(a)};_.m.addGeoJson=function(a,b){return _.le(this.b,a,b)};_.m.loadGeoJson=function(a,b,c){var d=this.b;_.S("data",function(e){e.il(d,a,b,c)})};_.m.toGeoJson=function(a){var b=this.b;_.S("data",function(c){c.cl(b,a)})};
|
||||
_.m.overrideStyle=function(a,b){this.f.overrideStyle(a,b)};_.m.revertStyle=function(a){this.f.revertStyle(a)};_.m.controls_changed=function(){this.get("controls")&&oe(this)};_.m.drawingMode_changed=function(){this.get("drawingMode")&&oe(this)};_.Xc(ne.prototype,{map:_.Fh,style:_.ib,controls:_.G(_.Qb(_.Pb(Dh))),controlPosition:_.G(_.Pb(_.kf)),drawingMode:_.G(_.Pb(Dh))});_.Gh={METRIC:0,IMPERIAL:1};_.Hh={DRIVING:"DRIVING",WALKING:"WALKING",BICYCLING:"BICYCLING",TRANSIT:"TRANSIT"};_.Ih={BEST_GUESS:"bestguess",OPTIMISTIC:"optimistic",PESSIMISTIC:"pessimistic"};_.Jh={BUS:"BUS",RAIL:"RAIL",SUBWAY:"SUBWAY",TRAIN:"TRAIN",TRAM:"TRAM"};_.Kh={LESS_WALKING:"LESS_WALKING",FEWER_TRANSFERS:"FEWER_TRANSFERS"};var Lh=_.Mb({routes:_.Qb(_.Rb(_.Cb))},!0);var Qd={main:[],common:["main"],util:["common"],adsense:["main"],controls:["util"],data:["util"],directions:["util","geometry"],distance_matrix:["util"],drawing:["main"],drawing_impl:["controls"],elevation:["util","geometry"],geocoder:["util"],geojson:["main"],imagery_viewer:["main"],geometry:["main"],infowindow:["util"],kml:["onion","util","map"],layers:["map"],map:["common"],marker:["util"],maxzoom:["util"],onion:["util","map"],overlay:["common"],panoramio:["main"],places:["main"],places_impl:["controls"],
|
||||
poly:["util","map","geometry"],search:["main"],search_impl:["onion"],stats:["util"],streetview:["util","geometry"],usage:["util"],visualization:["main"],visualization_impl:["onion"],weather:["main"],zombie:["main"]};var Mh=_.C.google.maps,Nh=Nd.b(),Oh=(0,_.v)(Nh.xa,Nh);Mh.__gjsload__=Oh;_.tb(Mh.modules,Oh);delete Mh.modules;var Ph=_.Mb({source:_.rh,webUrl:_.uh,iosDeepLinkId:_.uh});var Qh=_.Tb(_.Mb({placeId:_.uh,query:_.uh,location:_.qc}),function(a){if(a.placeId&&a.query)throw _.Kb("cannot set both placeId and query");if(!a.placeId&&!a.query)throw _.Kb("must set one of placeId or query");return a});_.z(se,_.N);
|
||||
_.Xc(se.prototype,{position:_.G(_.qc),title:_.uh,icon:_.G(_.Sb([_.rh,{Lg:Ub("url"),then:_.Mb({url:_.rh,scaledSize:_.G(Yb),size:_.G(Yb),origin:_.G(Xb),anchor:_.G(Xb),labelOrigin:_.G(Xb),path:_.Rb(function(a){return null==a})},!0)},{Lg:Ub("path"),then:_.Mb({path:_.Sb([_.rh,_.Pb(Eh)]),anchor:_.G(Xb),labelOrigin:_.G(Xb),fillColor:_.uh,fillOpacity:_.th,rotation:_.th,scale:_.th,strokeColor:_.uh,strokeOpacity:_.th,strokeWeight:_.th,url:_.Rb(function(a){return null==a})},!0)}])),label:_.G(_.Sb([_.rh,{Lg:Ub("text"),
|
||||
then:_.Mb({text:_.rh,fontSize:_.uh,fontWeight:_.uh,fontFamily:_.uh},!0)}])),shadow:_.ib,shape:_.ib,cursor:_.uh,clickable:_.vh,animation:_.ib,draggable:_.vh,visible:_.vh,flat:_.ib,zIndex:_.th,opacity:_.th,place:_.G(Qh),attribution:_.G(Ph)});var Rh=_.G(_.Ob(_.gd,"StreetViewPanorama"));_.z(_.te,se);_.te.prototype.map_changed=function(){this.__gm.set&&this.__gm.set.remove(this);var a=this.get("map");this.__gm.set=a&&a.__gm.ac;this.__gm.set&&_.bd(this.__gm.set,this)};_.te.MAX_ZINDEX=1E6;_.Xc(_.te.prototype,{map:_.Sb([_.Fh,Rh])});_.z(ve,_.N);_.m=ve.prototype;_.m.internalAnchor_changed=function(){var a=this.get("internalAnchor");we(this,"attribution",a);we(this,"place",a);we(this,"internalAnchorMap",a,"map");we(this,"internalAnchorPoint",a,"anchorPoint");a instanceof _.te?we(this,"internalAnchorPosition",a,"internalPosition"):we(this,"internalAnchorPosition",a,"position")};
|
||||
_.m.internalAnchorPoint_changed=ve.prototype.internalPixelOffset_changed=function(){var a=this.get("internalAnchorPoint")||_.wh,b=this.get("internalPixelOffset")||_.xh;this.set("pixelOffset",new _.J(b.width+Math.round(a.x),b.height+Math.round(a.y)))};_.m.internalAnchorPosition_changed=function(){var a=this.get("internalAnchorPosition");a&&this.set("position",a)};_.m.internalAnchorMap_changed=function(){this.get("internalAnchor")&&this.b.set("map",this.get("internalAnchorMap"))};
|
||||
_.m.xm=function(){var a=this.get("internalAnchor");!this.b.get("map")&&a&&a.get("map")&&this.set("internalAnchor",null)};_.m.internalContent_changed=function(){this.set("content",pe(this.get("internalContent")))};_.m.trigger=function(a){_.M.trigger(this.b,a)};_.m.close=function(){this.b.set("map",null)};_.z(_.xe,_.N);_.Xc(_.xe.prototype,{content:_.Sb([_.uh,_.Rb(Nb)]),position:_.G(_.qc),size:_.G(Yb),map:_.Sb([_.Fh,Rh]),anchor:_.G(_.Ob(_.N,"MVCObject")),zIndex:_.th});_.xe.prototype.open=function(a,b){this.set("anchor",b);b?!this.get("map")&&a&&this.set("map",a):this.set("map",a)};_.xe.prototype.close=function(){this.set("map",null)};_.ye=[];_.z(Ae,_.N);Ae.prototype.changed=function(a){if("map"==a||"panel"==a){var b=this;_.S("directions",function(c){c.Hl(b,a)})}"panel"==a&&_.ze(this.getPanel())};_.Xc(Ae.prototype,{directions:Lh,map:_.Fh,panel:_.G(_.Rb(Nb)),routeIndex:_.th});Be.prototype.route=function(a,b){_.S("directions",function(c){c.Ai(a,b,!0)})};Ce.prototype.getDistanceMatrix=function(a,b){_.S("distance_matrix",function(c){c.b(a,b)})};De.prototype.getElevationAlongPath=function(a,b){_.S("elevation",function(c){c.getElevationAlongPath(a,b)})};De.prototype.getElevationForLocations=function(a,b){_.S("elevation",function(c){c.getElevationForLocations(a,b)})};_.Sh=_.Ob(_.rc,"LatLngBounds");_.Ee.prototype.geocode=function(a,b){_.S("geocoder",function(c){c.geocode(a,b)})};_.z(_.Fe,_.N);_.Fe.prototype.map_changed=function(){var a=this;_.S("kml",function(b){b.b(a)})};_.Xc(_.Fe.prototype,{map:_.Fh,url:null,bounds:null,opacity:_.th});_.Uh={UNKNOWN:"UNKNOWN",OK:_.ha,INVALID_REQUEST:_.ba,DOCUMENT_NOT_FOUND:"DOCUMENT_NOT_FOUND",FETCH_ERROR:"FETCH_ERROR",INVALID_DOCUMENT:"INVALID_DOCUMENT",DOCUMENT_TOO_LARGE:"DOCUMENT_TOO_LARGE",LIMITS_EXCEEDED:"LIMITS_EXECEEDED",TIMED_OUT:"TIMED_OUT"};_.z(Ge,_.N);_.m=Ge.prototype;_.m.ee=function(){var a=this;_.S("kml",function(b){b.f(a)})};_.m.url_changed=Ge.prototype.ee;_.m.driveFileId_changed=Ge.prototype.ee;_.m.map_changed=Ge.prototype.ee;_.m.zIndex_changed=Ge.prototype.ee;_.Xc(Ge.prototype,{map:_.Fh,defaultViewport:null,metadata:null,status:null,url:_.uh,screenOverlays:_.vh,zIndex:_.th});_.z(_.He,_.N);_.Xc(_.He.prototype,{map:_.Fh});_.z(Ie,_.N);_.Xc(Ie.prototype,{map:_.Fh});_.z(Je,_.N);_.Xc(Je.prototype,{map:_.Fh});_.Le.prototype.Ce=!0;_.Le.prototype.b=_.sa(4);_.Le.prototype.Wh=!0;_.Le.prototype.f=_.sa(6);_.Ke={};_.Me("about:blank");_.Oe.prototype.Wh=!0;_.Oe.prototype.f=_.sa(5);_.Oe.prototype.Ce=!0;_.Oe.prototype.b=_.sa(3);_.Ne={};_.Qe("<!DOCTYPE html>",0);_.Qe("",0);_.Qe("<br>",0);var Tf="StopIteration"in _.C?_.C.StopIteration:{message:"StopIteration",stack:""};Te.prototype.next=function(){throw Tf;};_.z(Ue,Te);Ue.prototype.setPosition=function(a,b,c){if(this.node=a)this.f=_.Fa(b)?b:1!=this.node.nodeType?0:this.b?-1:1;_.Fa(c)&&(this.depth=c)};
|
||||
Ue.prototype.next=function(){if(this.j){if(!this.node||this.l&&0==this.depth)throw Tf;var a=this.node;var b=this.b?-1:1;if(this.f==b){var c=this.b?a.lastChild:a.firstChild;c?this.setPosition(c):this.setPosition(a,-1*b)}else(c=this.b?a.previousSibling:a.nextSibling)?this.setPosition(c):this.setPosition(a.parentNode,-1*b);this.depth+=this.f*(this.b?-1:1)}else this.j=!0;a=this.node;if(!this.node)throw Tf;return a};Ue.prototype.da=function(a){return a.node==this.node&&(!this.node||a.f==this.f)};
|
||||
Ue.prototype.splice=function(a){var b=this.node,c=this.b?1:-1;this.f==c&&(this.f=-1*c,this.depth+=this.f*(this.b?-1:1));this.b=!this.b;Ue.prototype.next.call(this);this.b=!this.b;c=_.Ja(arguments[0])?arguments[0]:arguments;for(var d=c.length-1;0<=d;d--)_.Re(c[d],b);_.Se(b)};_.z(Ve,Ue);Ve.prototype.next=function(){do Ve.Eb.next.call(this);while(-1==this.f);return this.node};var Cf;_.z(We,_.O);_.z(_.Xe,_.O);_.z(Ye,_.O);_.z(Ze,_.O);_.sf={};_.ef.prototype.da=function(a){return this==a||a instanceof _.ef&&this.size.da(a.size)&&this.heading==a.heading&&this.ga==a.ga};_.Xh=new _.ef(new _.Zb(256,256),0,0);_.Yh=!!(_.C.requestAnimationFrame&&_.C.performance&&_.C.performance.now);_.ff.prototype.fromLatLngToPoint=function(a,b){b=b||new _.H(0,0);var c=this.b;b.x=c.x+a.lng()*this.j;a=_.vb(Math.sin(_.rb(a.lat())),-(1-1E-15),1-1E-15);b.y=c.y+.5*Math.log((1+a)/(1-a))*-this.l;return b};_.ff.prototype.fromPointToLatLng=function(a,b){var c=this.b;return new _.K(_.sb(2*Math.atan(Math.exp((a.y-c.y)/-this.l))-Math.PI/2),(a.x-c.x)/this.j,b)};_.jf={japan_prequake:20,japan_postquake2010:24};_.Zh={NEAREST:"nearest",BEST:"best"};_.$h={DEFAULT:"default",OUTDOOR:"outdoor"};_.z(lf,_.gd);lf.prototype.visible_changed=function(){var a=this;!a.m&&a.getVisible()&&(a.m=!0,_.S("streetview",function(b){if(a.f)var c=a.f;b.Pm(a,c)}))};_.Xc(lf.prototype,{visible:_.vh,pano:_.uh,position:_.G(_.qc),pov:_.G(Ah),motionTracking:sh,photographerPov:null,location:null,links:_.Qb(_.Rb(_.Cb)),status:null,zoom:_.th,enableCloseButton:_.vh});lf.prototype.registerPanoProvider=function(a,b){this.set("panoProvider",{ri:a,options:b||{}})};mf.prototype.register=function(a){var b=this.l;var c=b.length;if(!c||a.zIndex>=b[0].zIndex)var d=0;else if(a.zIndex>=b[c-1].zIndex){for(d=0;1<c-d;){var e=d+c>>1;a.zIndex>=b[e].zIndex?c=e:d=e}d=c}else d=c;b.splice(d,0,a)};_.z(nf,kd);_.of.prototype.addListener=function(a,b){this.P.addListener(a,b)};_.of.prototype.addListenerOnce=function(a,b){this.P.addListenerOnce(a,b)};_.of.prototype.removeListener=function(a,b){this.P.removeListener(a,b)};_.of.prototype.b=_.sa(7);_.z(_.pf,_.N);_.pf.prototype.U=function(){var a=this;a.na||(a.na=_.C.setTimeout(function(){a.na=void 0;a.qa()},a.rk))};_.pf.prototype.B=function(){this.na&&_.C.clearTimeout(this.na);this.na=void 0;this.qa()};var Bf;_.z(uf,_.O);var Af;_.z(vf,_.O);_.z(wf,_.O);_.z(xf,_.O);var zf;_.z(yf,_.O);yf.prototype.getZoom=function(){return _.P(this,2)};yf.prototype.setZoom=function(a){this.data[2]=a};_.z(Ff,_.pf);var Lf={roadmap:0,satellite:2,hybrid:3,terrain:4},ai={0:1,2:2,3:2,4:2};_.m=Ff.prototype;_.m.Kh=_.Vc("center");_.m.Yg=_.Vc("zoom");_.m.changed=function(){var a=this.Kh(),b=this.Yg(),c=Mf(this);if(a&&!a.da(this.A)||this.Z!=b||this.la!=c)this.j||_.Nf(this.f),this.U(),this.Z=b,this.la=c;this.A=a};
|
||||
_.m.qa=function(){var a=Mf(this);if(this.j&&this.m)this.l!=a&&_.Nf(this.f);else{var b="",c=this.Kh(),d=this.Yg(),e=this.get("size");if(e){if(c&&(0,window.isFinite)(c.lat())&&(0,window.isFinite)(c.lng())&&1<d&&null!=a&&e&&e.width&&e.height&&this.b){_.qf(this.b,e);if(c=_.gf(this.D,c,d)){var f=new _.fc;f.O=Math.round(c.x-e.width/2);f.T=f.O+e.width;f.R=Math.round(c.y-e.height/2);f.V=f.R+e.height;c=f}else c=null;f=ai[a];c&&(this.m=!0,this.l=a,this.j&&this.f&&(b=_.cc(d,0,0),this.j.set({image:this.f,Ga:{min:_.dc(b,
|
||||
{W:c.O,Y:c.R}),max:_.dc(b,{W:c.T,Y:c.V})},size:{width:e.width,height:e.height}})),b=Pf(this,c,d,a,f))}this.f&&(_.qf(this.f,e),Qf(this,b))}}};
|
||||
_.m.div_changed=function(){var a=this.get("div"),b=this.b;if(a)if(b)a.appendChild(b);else{b=this.b=window.document.createElement("div");b.style.overflow="hidden";var c=this.f=window.document.createElement("img");_.M.addDomListener(b,"contextmenu",function(a){_.xc(a);_.Bc(a)});c.ontouchstart=c.ontouchmove=c.ontouchend=c.ontouchcancel=function(a){_.Ac(a);_.Bc(a)};_.qf(c,_.xh);a.appendChild(b);this.qa()}else b&&(_.Nf(b),this.b=null)};_.z(Wf,_.Bd);_.m=Wf.prototype;_.m.streetView_changed=function(){var a=this.get("streetView");a?a.set("standAlone",!1):this.set("streetView",this.__gm.B)};_.m.getDiv=function(){return this.__gm.$};_.m.panBy=function(a,b){var c=this.__gm;_.S("map",function(){_.M.trigger(c,"panby",a,b)})};_.m.panTo=function(a){var b=this.__gm;a=_.qc(a);_.S("map",function(){_.M.trigger(b,"panto",a)})};_.m.panToBounds=function(a,b){var c=this.__gm,d=_.uc(a);_.S("map",function(){_.M.trigger(c,"pantolatlngbounds",d,b)})};
|
||||
_.m.fitBounds=function(a,b){var c=this;a=_.uc(a);_.S("map",function(d){d.fitBounds(c,a,b)})};_.Xc(Wf.prototype,{bounds:null,streetView:Rh,center:_.G(_.qc),zoom:_.th,mapTypeId:_.uh,projection:null,heading:_.th,tilt:_.th,clickableIcons:sh});Zf.prototype.getMaxZoomAtLatLng=function(a,b){_.S("maxzoom",function(c){c.getMaxZoomAtLatLng(a,b)})};_.z($f,_.N);$f.prototype.changed=function(a){if("suppressInfoWindows"!=a&&"clickable"!=a){var b=this;_.S("onion",function(a){a.b(b)})}};_.Xc($f.prototype,{map:_.Fh,tableId:_.th,query:_.G(_.Sb([_.rh,_.Rb(_.Cb,"not an Object")]))});_.z(_.ag,_.N);_.ag.prototype.map_changed=function(){var a=this;_.S("overlay",function(b){b.xk(a)})};_.ag.preventMapHitsFrom=function(a){_.S("overlay",function(b){b.Ym(a)})};_.ag.preventMapHitsAndGesturesFrom=function(a){_.S("overlay",function(b){b.Xm(a)})};_.Xc(_.ag.prototype,{panes:null,projection:null,map:_.Sb([_.Fh,Rh])});var dg=fg(_.Ob(_.K,"LatLng"));_.z(_.hg,_.N);_.hg.prototype.map_changed=_.hg.prototype.visible_changed=function(){var a=this;_.S("poly",function(b){b.b(a)})};_.hg.prototype.center_changed=function(){_.M.trigger(this,"bounds_changed")};_.hg.prototype.radius_changed=_.hg.prototype.center_changed;_.hg.prototype.getBounds=function(){var a=this.get("radius"),b=this.get("center");if(b&&_.F(a)){var c=this.get("map");c=c&&c.__gm.get("baseMapType");return _.hf(b,a/_.cg(c))}return null};
|
||||
_.Xc(_.hg.prototype,{center:_.G(_.qc),draggable:_.vh,editable:_.vh,map:_.Fh,radius:_.th,visible:_.vh});_.z(ig,_.N);ig.prototype.map_changed=ig.prototype.visible_changed=function(){var a=this;_.S("poly",function(b){b.f(a)})};ig.prototype.getPath=function(){return this.get("latLngs").getAt(0)};ig.prototype.setPath=function(a){try{this.get("latLngs").setAt(0,eg(a))}catch(b){_.Lb(b)}};_.Xc(ig.prototype,{draggable:_.vh,editable:_.vh,map:_.Fh,visible:_.vh});_.z(_.jg,ig);_.jg.prototype.ab=!0;_.jg.prototype.getPaths=function(){return this.get("latLngs")};_.jg.prototype.setPaths=function(a){this.set("latLngs",gg(a))};_.z(_.kg,ig);_.kg.prototype.ab=!1;_.z(_.lg,_.N);_.lg.prototype.map_changed=_.lg.prototype.visible_changed=function(){var a=this;_.S("poly",function(b){b.j(a)})};_.Xc(_.lg.prototype,{draggable:_.vh,editable:_.vh,bounds:_.G(_.uc),map:_.Fh,visible:_.vh});_.z(mg,_.N);mg.prototype.map_changed=function(){var a=this;_.S("streetview",function(b){b.wk(a)})};_.Xc(mg.prototype,{map:_.Fh});_.ng.prototype.getPanorama=function(a,b){var c=this.b||void 0;_.S("streetview",function(d){_.S("geometry",function(e){d.pl(a,b,e.computeHeading,e.computeOffset,c)})})};_.ng.prototype.getPanoramaByLocation=function(a,b,c){this.getPanorama({location:a,radius:b,preference:50>(b||0)?"best":"nearest"},c)};_.ng.prototype.getPanoramaById=function(a,b){this.getPanorama({pano:a},b)};_.z(_.pg,_.N);_.m=_.pg.prototype;_.m.getTile=function(a,b,c){if(!a||!c)return null;var d=c.createElement("div");c={ia:a,zoom:b,cb:null};d.__gmimt=c;_.bd(this.b,d);if(this.f){var e=this.tileSize||new _.J(256,256),f=this.j(a,b);(c.cb=this.f({M:a.x,N:a.y,ca:b},e,d,f,function(){_.M.trigger(d,"load")})).setOpacity(og(this))}return d};_.m.releaseTile=function(a){a&&this.b.contains(a)&&(this.b.remove(a),(a=a.__gmimt.cb)&&a.release())};_.m.Hf=_.sa(8);_.m.opacity_changed=function(){var a=og(this);this.b.forEach(function(b){b.__gmimt.cb.setOpacity(a)})};
|
||||
_.m.triggersTileLoadEvent=!0;_.Xc(_.pg.prototype,{opacity:_.th});_.z(_.qg,_.N);_.qg.prototype.getTile=nh;_.qg.prototype.tileSize=new _.J(256,256);_.qg.prototype.triggersTileLoadEvent=!0;_.z(_.rg,_.qg);_.z(_.sg,_.N);_.Xc(_.sg.prototype,{attribution:_.G(Ph),place:_.G(Qh)});var bi={Animation:{BOUNCE:1,DROP:2,Bo:3,wo:4},Circle:_.hg,ControlPosition:_.kf,Data:ne,GroundOverlay:_.Fe,ImageMapType:_.pg,InfoWindow:_.xe,LatLng:_.K,LatLngBounds:_.rc,MVCArray:_.Zc,MVCObject:_.N,Map:Wf,MapTypeControlStyle:{DEFAULT:0,HORIZONTAL_BAR:1,DROPDOWN_MENU:2,INSET:3,INSET_LARGE:4},MapTypeId:_.ph,MapTypeRegistry:Ad,Marker:_.te,MarkerImage:function(a,b,c,d,e){this.url=a;this.size=b||e;this.origin=c;this.anchor=d;this.scaledSize=e;this.labelOrigin=null},NavigationControlStyle:{DEFAULT:0,SMALL:1,
|
||||
ANDROID:2,ZOOM_PAN:3,Co:4,fk:5},OverlayView:_.ag,Point:_.H,Polygon:_.jg,Polyline:_.kg,Rectangle:_.lg,ScaleControlStyle:{DEFAULT:0},Size:_.J,StreetViewPreference:_.Zh,StreetViewSource:_.$h,StrokePosition:{CENTER:0,INSIDE:1,OUTSIDE:2},SymbolPath:Eh,ZoomControlStyle:{DEFAULT:0,SMALL:1,LARGE:2,fk:3},event:_.M};_.ub(ne,{Feature:_.Ud,Geometry:Ed,GeometryCollection:_.ae,LineString:_.ce,LinearRing:_.de,MultiLineString:_.fe,MultiPoint:_.ge,MultiPolygon:_.ke,Point:_.Fd,Polygon:_.ie});
|
||||
_.ub(bi,{BicyclingLayer:_.He,DirectionsRenderer:Ae,DirectionsService:Be,DirectionsStatus:{OK:_.ha,UNKNOWN_ERROR:_.la,OVER_QUERY_LIMIT:_.ia,REQUEST_DENIED:_.ka,INVALID_REQUEST:_.ba,ZERO_RESULTS:_.ma,MAX_WAYPOINTS_EXCEEDED:_.ea,NOT_FOUND:_.fa},DirectionsTravelMode:_.Hh,DirectionsUnitSystem:_.Gh,DistanceMatrixService:Ce,DistanceMatrixStatus:{OK:_.ha,INVALID_REQUEST:_.ba,OVER_QUERY_LIMIT:_.ia,REQUEST_DENIED:_.ka,UNKNOWN_ERROR:_.la,MAX_ELEMENTS_EXCEEDED:_.da,MAX_DIMENSIONS_EXCEEDED:_.ca},DistanceMatrixElementStatus:{OK:_.ha,
|
||||
NOT_FOUND:_.fa,ZERO_RESULTS:_.ma},ElevationService:De,ElevationStatus:{OK:_.ha,UNKNOWN_ERROR:_.la,OVER_QUERY_LIMIT:_.ia,REQUEST_DENIED:_.ka,INVALID_REQUEST:_.ba,ro:"DATA_NOT_AVAILABLE"},FusionTablesLayer:$f,Geocoder:_.Ee,GeocoderLocationType:{ROOFTOP:"ROOFTOP",RANGE_INTERPOLATED:"RANGE_INTERPOLATED",GEOMETRIC_CENTER:"GEOMETRIC_CENTER",APPROXIMATE:"APPROXIMATE"},GeocoderStatus:{OK:_.ha,UNKNOWN_ERROR:_.la,OVER_QUERY_LIMIT:_.ia,REQUEST_DENIED:_.ka,INVALID_REQUEST:_.ba,ZERO_RESULTS:_.ma,ERROR:_.aa},KmlLayer:Ge,
|
||||
KmlLayerStatus:_.Uh,MaxZoomService:Zf,MaxZoomStatus:{OK:_.ha,ERROR:_.aa},SaveWidget:_.sg,StreetViewCoverageLayer:mg,StreetViewPanorama:lf,StreetViewService:_.ng,StreetViewStatus:{OK:_.ha,UNKNOWN_ERROR:_.la,ZERO_RESULTS:_.ma},StyledMapType:_.rg,TrafficLayer:Ie,TrafficModel:_.Ih,TransitLayer:Je,TransitMode:_.Jh,TransitRoutePreference:_.Kh,TravelMode:_.Hh,UnitSystem:_.Gh});_.Sd("main",{});var vg=/'/g,wg;var qe=arguments[0];
|
||||
window.google.maps.Load(function(a,b){var c=window.google.maps;Ag();var d=Bg(c);_.T=new Ze(a);_.ci=Math.random()<_.P(_.T,0,1);_.di=Math.round(1E15*Math.random()).toString(36);_.Vf=xg();_.Th=yg();_.Vh=new _.Zc;_.Wh=b;for(a=0;a<_.zd(_.T,8);++a)_.sf[_.xd(_.T,8,a)]=!0;a=new _.Xe(_.T.data[3]);re(_.Q(a,0));_.tb(bi,function(a,b){c[a]=b});c.version=_.Q(a,1);window.setTimeout(function(){_.Td(["util","stats"],function(a,b){a.f.b();a.j();d&&b.b.b({ev:"api_alreadyloaded",client:_.Q(_.T,6),key:_.bf()})})},5E3);
|
||||
(a=_.Q(_.T,11))&&_.Td(_.vd(_.T,12),zg(a),!0)});}).call(this,{});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,834 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel
|
||||
{
|
||||
/**
|
||||
* Document properties
|
||||
*
|
||||
* @var PHPExcel_DocumentProperties
|
||||
*/
|
||||
private $_properties;
|
||||
|
||||
/**
|
||||
* Document security
|
||||
*
|
||||
* @var PHPExcel_DocumentSecurity
|
||||
*/
|
||||
private $_security;
|
||||
|
||||
/**
|
||||
* Collection of Worksheet objects
|
||||
*
|
||||
* @var PHPExcel_Worksheet[]
|
||||
*/
|
||||
private $_workSheetCollection = array();
|
||||
|
||||
/**
|
||||
* Active sheet index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_activeSheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Named ranges
|
||||
*
|
||||
* @var PHPExcel_NamedRange[]
|
||||
*/
|
||||
private $_namedRanges = array();
|
||||
|
||||
/**
|
||||
* CellXf supervisor
|
||||
*
|
||||
* @var PHPExcel_Style
|
||||
*/
|
||||
private $_cellXfSupervisor;
|
||||
|
||||
/**
|
||||
* CellXf collection
|
||||
*
|
||||
* @var PHPExcel_Style[]
|
||||
*/
|
||||
private $_cellXfCollection = array();
|
||||
|
||||
/**
|
||||
* CellStyleXf collection
|
||||
*
|
||||
* @var PHPExcel_Style[]
|
||||
*/
|
||||
private $_cellStyleXfCollection = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel with one Worksheet
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise worksheet collection and add one worksheet
|
||||
$this->_workSheetCollection = array();
|
||||
$this->_workSheetCollection[] = new PHPExcel_Worksheet($this);
|
||||
$this->_activeSheetIndex = 0;
|
||||
|
||||
// Create document properties
|
||||
$this->_properties = new PHPExcel_DocumentProperties();
|
||||
|
||||
// Create document security
|
||||
$this->_security = new PHPExcel_DocumentSecurity();
|
||||
|
||||
// Set named ranges
|
||||
$this->_namedRanges = array();
|
||||
|
||||
// Create the cellXf supervisor
|
||||
$this->_cellXfSupervisor = new PHPExcel_Style(true);
|
||||
$this->_cellXfSupervisor->bindParent($this);
|
||||
|
||||
// Create the default style
|
||||
$this->addCellXf(new PHPExcel_Style);
|
||||
$this->addCellStyleXf(new PHPExcel_Style);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disconnect all worksheets from this PHPExcel workbook object,
|
||||
* typically so that the PHPExcel object can be unset
|
||||
*
|
||||
*/
|
||||
public function disconnectWorksheets() {
|
||||
foreach($this->_workSheetCollection as $k => &$worksheet) {
|
||||
$worksheet->disconnectCells();
|
||||
$this->_workSheetCollection[$k] = null;
|
||||
}
|
||||
unset($worksheet);
|
||||
$this->_workSheetCollection = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties
|
||||
*
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->_properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties
|
||||
*
|
||||
* @param PHPExcel_DocumentProperties $pValue
|
||||
*/
|
||||
public function setProperties(PHPExcel_DocumentProperties $pValue)
|
||||
{
|
||||
$this->_properties = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get security
|
||||
*
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
public function getSecurity()
|
||||
{
|
||||
return $this->_security;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set security
|
||||
*
|
||||
* @param PHPExcel_DocumentSecurity $pValue
|
||||
*/
|
||||
public function setSecurity(PHPExcel_DocumentSecurity $pValue)
|
||||
{
|
||||
$this->_security = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active sheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getActiveSheet()
|
||||
{
|
||||
return $this->_workSheetCollection[$this->_activeSheetIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create sheet and add it to this workbook
|
||||
*
|
||||
* @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
|
||||
* @return PHPExcel_Worksheet
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createSheet($iSheetIndex = NULL)
|
||||
{
|
||||
$newSheet = new PHPExcel_Worksheet($this);
|
||||
$this->addSheet($newSheet, $iSheetIndex);
|
||||
return $newSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chech if a sheet with a specified name already exists
|
||||
*
|
||||
* @param string $pSheetName Name of the worksheet to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function sheetNameExists($pSheetName)
|
||||
{
|
||||
return ($this->getSheetByName($pSheetName) !== NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet
|
||||
* @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
|
||||
* @return PHPExcel_Worksheet
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL)
|
||||
{
|
||||
if ($this->sheetNameExists($pSheet->getTitle())) {
|
||||
throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first.");
|
||||
}
|
||||
|
||||
if($iSheetIndex === NULL) {
|
||||
if ($this->_activeSheetIndex < 0) {
|
||||
$this->_activeSheetIndex = 0;
|
||||
}
|
||||
$this->_workSheetCollection[] = $pSheet;
|
||||
} else {
|
||||
// Insert the sheet at the requested index
|
||||
array_splice(
|
||||
$this->_workSheetCollection,
|
||||
$iSheetIndex,
|
||||
0,
|
||||
array($pSheet)
|
||||
);
|
||||
|
||||
// Adjust active sheet index if necessary
|
||||
if ($this->_activeSheetIndex >= $iSheetIndex) {
|
||||
++$this->_activeSheetIndex;
|
||||
}
|
||||
}
|
||||
return $pSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sheet by index
|
||||
*
|
||||
* @param int $pIndex Active sheet index
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removeSheetByIndex($pIndex = 0)
|
||||
{
|
||||
if ($pIndex > count($this->_workSheetCollection) - 1) {
|
||||
throw new Exception("Sheet index is out of bounds.");
|
||||
} else {
|
||||
array_splice($this->_workSheetCollection, $pIndex, 1);
|
||||
}
|
||||
// Adjust active sheet index if necessary
|
||||
if (($this->_activeSheetIndex >= $pIndex) &&
|
||||
($pIndex > count($this->_workSheetCollection) - 1)) {
|
||||
--$this->_activeSheetIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet by index
|
||||
*
|
||||
* @param int $pIndex Sheet index
|
||||
* @return PHPExcel_Worksheet
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getSheet($pIndex = 0)
|
||||
{
|
||||
if ($pIndex > count($this->_workSheetCollection) - 1) {
|
||||
throw new Exception("Sheet index is out of bounds.");
|
||||
} else {
|
||||
return $this->_workSheetCollection[$pIndex];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all sheets
|
||||
*
|
||||
* @return PHPExcel_Worksheet[]
|
||||
*/
|
||||
public function getAllSheets()
|
||||
{
|
||||
return $this->_workSheetCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet by name
|
||||
*
|
||||
* @param string $pName Sheet name
|
||||
* @return PHPExcel_Worksheet
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getSheetByName($pName = '')
|
||||
{
|
||||
$worksheetCount = count($this->_workSheetCollection);
|
||||
for ($i = 0; $i < $worksheetCount; ++$i) {
|
||||
if ($this->_workSheetCollection[$i]->getTitle() == $pName) {
|
||||
return $this->_workSheetCollection[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for sheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet
|
||||
* @return Sheet index
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getIndex(PHPExcel_Worksheet $pSheet)
|
||||
{
|
||||
foreach ($this->_workSheetCollection as $key => $value) {
|
||||
if ($value->getHashCode() == $pSheet->getHashCode()) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set index for sheet by sheet name.
|
||||
*
|
||||
* @param string $sheetName Sheet name to modify index for
|
||||
* @param int $newIndex New index for the sheet
|
||||
* @return New sheet index
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setIndexByName($sheetName, $newIndex)
|
||||
{
|
||||
$oldIndex = $this->getIndex($this->getSheetByName($sheetName));
|
||||
$pSheet = array_splice(
|
||||
$this->_workSheetCollection,
|
||||
$oldIndex,
|
||||
1
|
||||
);
|
||||
array_splice(
|
||||
$this->_workSheetCollection,
|
||||
$newIndex,
|
||||
0,
|
||||
$pSheet
|
||||
);
|
||||
return $newIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetCount()
|
||||
{
|
||||
return count($this->_workSheetCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active sheet index
|
||||
*
|
||||
* @return int Active sheet index
|
||||
*/
|
||||
public function getActiveSheetIndex()
|
||||
{
|
||||
return $this->_activeSheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active sheet index
|
||||
*
|
||||
* @param int $pIndex Active sheet index
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function setActiveSheetIndex($pIndex = 0)
|
||||
{
|
||||
if ($pIndex > count($this->_workSheetCollection) - 1) {
|
||||
throw new Exception("Active sheet index is out of bounds.");
|
||||
} else {
|
||||
$this->_activeSheetIndex = $pIndex;
|
||||
}
|
||||
return $this->getActiveSheet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active sheet index by name
|
||||
*
|
||||
* @param string $pValue Sheet title
|
||||
* @return PHPExcel_Worksheet
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setActiveSheetIndexByName($pValue = '')
|
||||
{
|
||||
if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) {
|
||||
$this->setActiveSheetIndex($this->getIndex($worksheet));
|
||||
return $worksheet;
|
||||
}
|
||||
|
||||
throw new Exception('Workbook does not contain sheet:' . $pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet names
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSheetNames()
|
||||
{
|
||||
$returnValue = array();
|
||||
$worksheetCount = $this->getSheetCount();
|
||||
for ($i = 0; $i < $worksheetCount; ++$i) {
|
||||
$returnValue[] = $this->getSheet($i)->getTitle();
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add external sheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet External sheet to add
|
||||
* @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) {
|
||||
if ($this->sheetNameExists($pSheet->getTitle())) {
|
||||
throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first.");
|
||||
}
|
||||
|
||||
// count how many cellXfs there are in this workbook currently, we will need this below
|
||||
$countCellXfs = count($this->_cellXfCollection);
|
||||
|
||||
// copy all the shared cellXfs from the external workbook and append them to the current
|
||||
foreach ($pSheet->getParent()->getCellXfCollection() as $cellXf) {
|
||||
$this->addCellXf(clone $cellXf);
|
||||
}
|
||||
|
||||
// move sheet to this workbook
|
||||
$pSheet->rebindParent($this);
|
||||
|
||||
// update the cellXfs
|
||||
foreach ($pSheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $pSheet->getCell($cellID);
|
||||
$cell->setXfIndex( $cell->getXfIndex() + $countCellXfs );
|
||||
}
|
||||
|
||||
return $this->addSheet($pSheet, $iSheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get named ranges
|
||||
*
|
||||
* @return PHPExcel_NamedRange[]
|
||||
*/
|
||||
public function getNamedRanges() {
|
||||
return $this->_namedRanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add named range
|
||||
*
|
||||
* @param PHPExcel_NamedRange $namedRange
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function addNamedRange(PHPExcel_NamedRange $namedRange) {
|
||||
if ($namedRange->getScope() == null) {
|
||||
// global scope
|
||||
$this->_namedRanges[$namedRange->getName()] = $namedRange;
|
||||
} else {
|
||||
// local scope
|
||||
$this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get named range
|
||||
*
|
||||
* @param string $namedRange
|
||||
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
||||
* @return PHPExcel_NamedRange|null
|
||||
*/
|
||||
public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
|
||||
$returnValue = null;
|
||||
|
||||
if ($namedRange != '' && ($namedRange !== NULL)) {
|
||||
// first look for global defined name
|
||||
if (isset($this->_namedRanges[$namedRange])) {
|
||||
$returnValue = $this->_namedRanges[$namedRange];
|
||||
}
|
||||
|
||||
// then look for local defined name (has priority over global defined name if both names exist)
|
||||
if (($pSheet !== NULL) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
|
||||
$returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange];
|
||||
}
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove named range
|
||||
*
|
||||
* @param string $namedRange
|
||||
* @param PHPExcel_Worksheet|null $pSheet Scope: use null for global scope.
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
|
||||
if ($pSheet === NULL) {
|
||||
if (isset($this->_namedRanges[$namedRange])) {
|
||||
unset($this->_namedRanges[$namedRange]);
|
||||
}
|
||||
} else {
|
||||
if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
|
||||
unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get worksheet iterator
|
||||
*
|
||||
* @return PHPExcel_WorksheetIterator
|
||||
*/
|
||||
public function getWorksheetIterator() {
|
||||
return new PHPExcel_WorksheetIterator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy workbook (!= clone!)
|
||||
*
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function copy() {
|
||||
$copied = clone $this;
|
||||
|
||||
$worksheetCount = count($this->_workSheetCollection);
|
||||
for ($i = 0; $i < $worksheetCount; ++$i) {
|
||||
$this->_workSheetCollection[$i] = $this->_workSheetCollection[$i]->copy();
|
||||
$this->_workSheetCollection[$i]->rebindParent($this);
|
||||
}
|
||||
|
||||
return $copied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
foreach($this as $key => $val) {
|
||||
if (is_object($val) || (is_array($val))) {
|
||||
$this->{$key} = unserialize(serialize($val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the workbook collection of cellXfs
|
||||
*
|
||||
* @return PHPExcel_Style[]
|
||||
*/
|
||||
public function getCellXfCollection()
|
||||
{
|
||||
return $this->_cellXfCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cellXf by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
public function getCellXfByIndex($pIndex = 0)
|
||||
{
|
||||
return $this->_cellXfCollection[$pIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cellXf by hash code
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style|false
|
||||
*/
|
||||
public function getCellXfByHashCode($pValue = '')
|
||||
{
|
||||
foreach ($this->_cellXfCollection as $cellXf) {
|
||||
if ($cellXf->getHashCode() == $pValue) {
|
||||
return $cellXf;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if style exists in style collection
|
||||
*
|
||||
* @param PHPExcel_Style $style
|
||||
* @return boolean
|
||||
*/
|
||||
public function cellXfExists($pCellStyle = null)
|
||||
{
|
||||
return in_array($pCellStyle, $this->_cellXfCollection, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default style
|
||||
*
|
||||
* @return PHPExcel_Style
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getDefaultStyle()
|
||||
{
|
||||
if (isset($this->_cellXfCollection[0])) {
|
||||
return $this->_cellXfCollection[0];
|
||||
}
|
||||
throw new Exception('No default style found for this workbook');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cellXf to the workbook
|
||||
*
|
||||
* @param PHPExcel_Style $style
|
||||
*/
|
||||
public function addCellXf(PHPExcel_Style $style)
|
||||
{
|
||||
$this->_cellXfCollection[] = $style;
|
||||
$style->setIndex(count($this->_cellXfCollection) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove cellXf by index. It is ensured that all cells get their xf index updated.
|
||||
*
|
||||
* @param int $pIndex Index to cellXf
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removeCellXfByIndex($pIndex = 0)
|
||||
{
|
||||
if ($pIndex > count($this->_cellXfCollection) - 1) {
|
||||
throw new Exception("CellXf index is out of bounds.");
|
||||
} else {
|
||||
// first remove the cellXf
|
||||
array_splice($this->_cellXfCollection, $pIndex, 1);
|
||||
|
||||
// then update cellXf indexes for cells
|
||||
foreach ($this->_workSheetCollection as $worksheet) {
|
||||
foreach ($worksheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $worksheet->getCell($cellID);
|
||||
$xfIndex = $cell->getXfIndex();
|
||||
if ($xfIndex > $pIndex ) {
|
||||
// decrease xf index by 1
|
||||
$cell->setXfIndex($xfIndex - 1);
|
||||
} else if ($xfIndex == $pIndex) {
|
||||
// set to default xf index 0
|
||||
$cell->setXfIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cellXf supervisor
|
||||
*
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
public function getCellXfSupervisor()
|
||||
{
|
||||
return $this->_cellXfSupervisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the workbook collection of cellStyleXfs
|
||||
*
|
||||
* @return PHPExcel_Style[]
|
||||
*/
|
||||
public function getCellStyleXfCollection()
|
||||
{
|
||||
return $this->_cellStyleXfCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cellStyleXf by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
public function getCellStyleXfByIndex($pIndex = 0)
|
||||
{
|
||||
return $this->_cellStyleXfCollection[$pIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cellStyleXf by hash code
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style|false
|
||||
*/
|
||||
public function getCellStyleXfByHashCode($pValue = '')
|
||||
{
|
||||
foreach ($this->_cellXfStyleCollection as $cellStyleXf) {
|
||||
if ($cellStyleXf->getHashCode() == $pValue) {
|
||||
return $cellStyleXf;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a cellStyleXf to the workbook
|
||||
*
|
||||
* @param PHPExcel_Style $pStyle
|
||||
*/
|
||||
public function addCellStyleXf(PHPExcel_Style $pStyle)
|
||||
{
|
||||
$this->_cellStyleXfCollection[] = $pStyle;
|
||||
$pStyle->setIndex(count($this->_cellStyleXfCollection) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove cellStyleXf by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removeCellStyleXfByIndex($pIndex = 0)
|
||||
{
|
||||
if ($pIndex > count($this->_cellStyleXfCollection) - 1) {
|
||||
throw new Exception("CellStyleXf index is out of bounds.");
|
||||
} else {
|
||||
array_splice($this->_cellStyleXfCollection, $pIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells
|
||||
* and columns in the workbook
|
||||
*/
|
||||
public function garbageCollect()
|
||||
{
|
||||
// how many references are there to each cellXf ?
|
||||
$countReferencesCellXf = array();
|
||||
foreach ($this->_cellXfCollection as $index => $cellXf) {
|
||||
$countReferencesCellXf[$index] = 0;
|
||||
}
|
||||
|
||||
foreach ($this->getWorksheetIterator() as $sheet) {
|
||||
|
||||
// from cells
|
||||
foreach ($sheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
++$countReferencesCellXf[$cell->getXfIndex()];
|
||||
}
|
||||
|
||||
// from row dimensions
|
||||
foreach ($sheet->getRowDimensions() as $rowDimension) {
|
||||
if ($rowDimension->getXfIndex() !== null) {
|
||||
++$countReferencesCellXf[$rowDimension->getXfIndex()];
|
||||
}
|
||||
}
|
||||
|
||||
// from column dimensions
|
||||
foreach ($sheet->getColumnDimensions() as $columnDimension) {
|
||||
++$countReferencesCellXf[$columnDimension->getXfIndex()];
|
||||
}
|
||||
}
|
||||
|
||||
// remove cellXfs without references and create mapping so we can update xfIndex
|
||||
// for all cells and columns
|
||||
$countNeededCellXfs = 0;
|
||||
foreach ($this->_cellXfCollection as $index => $cellXf) {
|
||||
if ($countReferencesCellXf[$index] > 0 || $index == 0) { // we must never remove the first cellXf
|
||||
++$countNeededCellXfs;
|
||||
} else {
|
||||
unset($this->_cellXfCollection[$index]);
|
||||
}
|
||||
$map[$index] = $countNeededCellXfs - 1;
|
||||
}
|
||||
$this->_cellXfCollection = array_values($this->_cellXfCollection);
|
||||
|
||||
// update the index for all cellXfs
|
||||
foreach ($this->_cellXfCollection as $i => $cellXf) {
|
||||
$cellXf->setIndex($i);
|
||||
}
|
||||
|
||||
// make sure there is always at least one cellXf (there should be)
|
||||
if (empty($this->_cellXfCollection)) {
|
||||
$this->_cellXfCollection[] = new PHPExcel_Style();
|
||||
}
|
||||
|
||||
// update the xfIndex for all cells, row dimensions, column dimensions
|
||||
foreach ($this->getWorksheetIterator() as $sheet) {
|
||||
|
||||
// for all cells
|
||||
foreach ($sheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
$cell->setXfIndex( $map[$cell->getXfIndex()] );
|
||||
}
|
||||
|
||||
// for all row dimensions
|
||||
foreach ($sheet->getRowDimensions() as $rowDimension) {
|
||||
if ($rowDimension->getXfIndex() !== null) {
|
||||
$rowDimension->setXfIndex( $map[$rowDimension->getXfIndex()] );
|
||||
}
|
||||
}
|
||||
|
||||
// for all column dimensions
|
||||
foreach ($sheet->getColumnDimensions() as $columnDimension) {
|
||||
$columnDimension->setXfIndex( $map[$columnDimension->getXfIndex()] );
|
||||
}
|
||||
}
|
||||
|
||||
// also do garbage collection for all the sheets
|
||||
foreach ($this->getWorksheetIterator() as $sheet) {
|
||||
$sheet->garbageCollect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
PHPExcel_Autoloader::Register();
|
||||
// As we always try to run the autoloader before anything else, we can use it to do a few
|
||||
// simple checks and initialisations
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
PHPExcel_Shared_String::buildCharacterSets();
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Autoloader
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Autoloader
|
||||
{
|
||||
/**
|
||||
* Register the Autoloader with SPL
|
||||
*
|
||||
*/
|
||||
public static function Register() {
|
||||
if (function_exists('__autoload')) {
|
||||
// Register any existing autoloader function with SPL, so we don't get any clashes
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
// Register ourselves with SPL
|
||||
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
|
||||
} // function Register()
|
||||
|
||||
|
||||
/**
|
||||
* Autoload a class identified by name
|
||||
*
|
||||
* @param string $pClassName Name of the object to load
|
||||
*/
|
||||
public static function Load($pClassName){
|
||||
if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
|
||||
// Either already loaded, or not a PHPExcel class request
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$pClassFilePath = PHPEXCEL_ROOT .
|
||||
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
|
||||
'.php';
|
||||
|
||||
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
|
||||
// Can't load
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
require($pClassFilePath);
|
||||
} // function Load()
|
||||
|
||||
}
|
|
@ -0,0 +1,280 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_APC
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @access public
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
|
||||
}
|
||||
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$cellID.' in APC');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if ($this->_currentObject !== NULL) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the APC cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if ($this->_cachePrefix === NULL) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('apc_store')) {
|
||||
return false;
|
||||
}
|
||||
if (apc_sma_info() === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,252 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_CacheBase
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
||||
|
||||
/**
|
||||
* Parent worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
protected $_parent;
|
||||
|
||||
/**
|
||||
* The currently active Cell
|
||||
*
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
protected $_currentObject = null;
|
||||
|
||||
/**
|
||||
* Coordinate address of the currently active Cell
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_currentObjectID = null;
|
||||
|
||||
|
||||
/**
|
||||
* Flag indicating whether the currently active Cell requires saving
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_currentCellIsDirty = true;
|
||||
|
||||
/**
|
||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||
* and indexed by their coordinate address within the worksheet
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
protected $_cellCache = array();
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
// Set our parent worksheet.
|
||||
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
|
||||
// they are woken from a serialized state
|
||||
$this->_parent = $parent;
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry exists in the cache
|
||||
return isset($this->_cellCache[$pCoord]);
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell) {
|
||||
return $this->addCacheData($cell->getCoordinate(),$cell);
|
||||
} // function updateCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
}
|
||||
|
||||
if (is_object($this->_cellCache[$pCoord])) {
|
||||
$this->_cellCache[$pCoord]->detach();
|
||||
unset($this->_cellCache[$pCoord]);
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
return array_keys($this->_cellCache);
|
||||
} // function getCellList()
|
||||
|
||||
|
||||
/**
|
||||
* Sort the list of all cell addresses currently held in cache by row and column
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSortedCellList() {
|
||||
$sortKeys = array();
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
list($column,$row) = sscanf($coord,'%[A-Z]%d');
|
||||
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
|
||||
}
|
||||
ksort($sortKeys);
|
||||
|
||||
return array_values($sortKeys);
|
||||
} // function sortCellList()
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get highest worksheet column and highest row that have cell records
|
||||
*
|
||||
* @return array Highest column name and highest row number
|
||||
*/
|
||||
public function getHighestRowAndColumn()
|
||||
{
|
||||
// Lookup highest column and highest row
|
||||
$col = array('A' => '1A');
|
||||
$row = array(1);
|
||||
foreach ($this->getCellList() as $coord) {
|
||||
list($c,$r) = sscanf($coord,'%[A-Z]%d');
|
||||
$row[$r] = $r;
|
||||
$col[$c] = strlen($c).$c;
|
||||
}
|
||||
if (!empty($row)) {
|
||||
// Determine highest column and row
|
||||
$highestRow = max($row);
|
||||
$highestColumn = substr(max($col),1);
|
||||
}
|
||||
|
||||
return array( 'row' => $highestRow,
|
||||
'column' => $highestColumn
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get highest worksheet column
|
||||
*
|
||||
* @return string Highest column name
|
||||
*/
|
||||
public function getHighestColumn()
|
||||
{
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
return $colRow['column'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get highest worksheet row
|
||||
*
|
||||
* @return int Highest row number
|
||||
*/
|
||||
public function getHighestRow()
|
||||
{
|
||||
$colRow = $this->getHighestRowAndColumn();
|
||||
return $colRow['row'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a unique ID for cache referencing
|
||||
*
|
||||
* @return string Unique Reference
|
||||
*/
|
||||
protected function _getUniqueID() {
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
return uniqid($baseUnique,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
$this->_parent = $parent;
|
||||
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
|
||||
$this->_currentObject->attach($parent);
|
||||
}
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_DiscISAM
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileName = NULL;
|
||||
|
||||
/**
|
||||
* File handle for this cache file
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_fileHandle = NULL;
|
||||
|
||||
/**
|
||||
* Directory/Folder where the cache file is located
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cacheDirectory = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
fseek($this->_fileHandle,0,SEEK_END);
|
||||
$offset = ftell($this->_fileHandle);
|
||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||
'sz' => ftell($this->_fileHandle) - $offset
|
||||
);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
// Copy the existing cell cache file
|
||||
copy ($this->_fileName,$newFileName);
|
||||
$this->_fileName = $newFileName;
|
||||
// Open the copied cell cache file
|
||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
|
||||
? $arguments['dir']
|
||||
: PHPExcel_Shared_File::sys_get_temp_dir();
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_fileHandle)) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
|
||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_fileHandle)) {
|
||||
fclose($this->_fileHandle);
|
||||
unlink($this->_fileName);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_ICache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Fetch a cell from cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to retrieve
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord);
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList();
|
||||
|
||||
/**
|
||||
* Get the list of all cell addresses currently held in cache sorted by column and row
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSortedCellList();
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent);
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable();
|
||||
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Igbinary
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('igbinary_serialize')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,298 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memcache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
|
||||
/**
|
||||
* Memcache interface
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_memcache = null;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$obj = serialize($this->_currentObject);
|
||||
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
|
||||
}
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in Memcache
|
||||
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from Memcache
|
||||
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
|
||||
}
|
||||
if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$cellID.' in MemCache');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the Memcache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->_cachePrefix)) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
|
||||
// Set a new Memcache object and connect to the Memcache server
|
||||
$this->_memcache = new Memcache();
|
||||
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
|
||||
throw new Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort);
|
||||
}
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Memcache error handler
|
||||
*
|
||||
* @param string $host Memcache server
|
||||
* @param integer $port Memcache port
|
||||
* @throws Exception
|
||||
*/
|
||||
public function failureCallback($host, $port) {
|
||||
throw new Exception('memcache '.$host.':'.$port.' failed');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('memcache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
$this->_cellCache[$pCoord] = $cell;
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return requested entry
|
||||
return $this->_cellCache[$pCoord];
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
|
||||
$newCollection = array();
|
||||
foreach($this->_cellCache as $k => &$cell) {
|
||||
$newCollection[$k] = clone $cell;
|
||||
$newCollection[$k]->attach($parent);
|
||||
}
|
||||
|
||||
$this->_cellCache = $newCollection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
||||
foreach($this->_cellCache as $k => &$cell) {
|
||||
$cell->detach();
|
||||
$this->_cellCache[$k] = null;
|
||||
}
|
||||
unset($cell);
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemoryGZip
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemorySerialized
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_PHPTemp
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Name of the file for this cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_fileHandle = null;
|
||||
|
||||
/**
|
||||
* Memory limit to use before reverting to file cache
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_memoryCacheSize = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
fseek($this->_fileHandle,0,SEEK_END);
|
||||
$offset = ftell($this->_fileHandle);
|
||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||
'sz' => ftell($this->_fileHandle) - $offset
|
||||
);
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Open a new stream for the cell cache data
|
||||
$newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
|
||||
// Copy the existing cell cache data to the new stream
|
||||
fseek($this->_fileHandle,0);
|
||||
while (!feof($this->_fileHandle)) {
|
||||
fwrite($newFileHandle,fread($this->_fileHandle, 1024));
|
||||
}
|
||||
$this->_fileHandle = $newFileHandle;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the php://temp file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_fileHandle)) {
|
||||
$this->_fileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_fileHandle)) {
|
||||
fclose($this->_fileHandle);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_SQLite
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_DBHandle = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
|
||||
$cellResult = $cellResultSet->fetchSingle();
|
||||
$this->_currentObject = unserialize($cellResult);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
|
||||
if ($cellResultSet === false) {
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
} elseif ($cellResultSet->numRows() == 0) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
if (!$this->_DBHandle->queryExec($query))
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
|
||||
$this->_currentCellIsDirty = false;
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
||||
$cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
|
||||
if ($cellIdsResult === false)
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
|
||||
$cellKeys = array();
|
||||
foreach($cellIdsResult as $row) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
} // function getCellList()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
// Get a new id for the new table name
|
||||
$tableName = str_replace('.','_',$this->_getUniqueID());
|
||||
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_'.$this->_TableName))
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->_TableName = $tableName;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_DBHandle)) {
|
||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
|
||||
$this->_DBHandle = new SQLiteDatabase($_DBName);
|
||||
if ($this->_DBHandle === false)
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
|
||||
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$this->_DBHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('sqlite_open')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,277 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_SQLite3
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Database table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_TableName = null;
|
||||
|
||||
/**
|
||||
* Database handle
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_DBHandle = null;
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$query = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
|
||||
$query->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
|
||||
$query->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
|
||||
$result = $query->execute();
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$cellResult = $this->_DBHandle->querySingle($query);
|
||||
if ($cellResult === false) {
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
} elseif (is_null($cellResult)) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
|
||||
$this->_currentObject = unserialize($cellResult);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$cellResult = $this->_DBHandle->querySingle($query);
|
||||
if ($cellResult === false) {
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
} elseif (is_null($cellResult)) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
}
|
||||
|
||||
// Check if the requested entry exists in the cache
|
||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
||||
$result = $this->_DBHandle->exec($query);
|
||||
if ($result === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
$this->_currentCellIsDirty = false;
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
$query = "SELECT id FROM kvp_".$this->_TableName;
|
||||
$cellIdsResult = $this->_DBHandle->query($query);
|
||||
if ($cellIdsResult === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
$cellKeys = array();
|
||||
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
|
||||
$cellKeys[] = $row['id'];
|
||||
}
|
||||
|
||||
return $cellKeys;
|
||||
} // function getCellList()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
// Get a new id for the new table name
|
||||
$tableName = str_replace('.','_',$this->_getUniqueID());
|
||||
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||
AS SELECT * FROM kvp_'.$this->_TableName))
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
|
||||
// Copy the existing cell cache file
|
||||
$this->_TableName = $tableName;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_DBHandle)) {
|
||||
$this->_TableName = str_replace('.','_',$this->_getUniqueID());
|
||||
$_DBName = ':memory:';
|
||||
|
||||
$this->_DBHandle = new SQLite3($_DBName);
|
||||
if ($this->_DBHandle === false)
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
|
||||
throw new Exception($this->_DBHandle->lastErrorMsg());
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_DBHandle)) {
|
||||
$this->_DBHandle->close();
|
||||
}
|
||||
$this->_DBHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!class_exists('SQLite3',FALSE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,280 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Wincache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$obj = serialize($this->_currentObject);
|
||||
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
|
||||
if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
|
||||
}
|
||||
} else {
|
||||
if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
|
||||
}
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in cache
|
||||
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
$obj = null;
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from Wincache
|
||||
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new Exception('Cell entry '.$cellID.' no longer exists in Wincache');
|
||||
}
|
||||
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$cellID.' in Wincache');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the WinCache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
|
||||
* @param array of mixed $arguments Additional initialisation arguments
|
||||
*/
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->_cachePrefix)) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether the caching method is currently available
|
||||
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('wincache_ucache_add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorageFactory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorageFactory
|
||||
{
|
||||
const cache_in_memory = 'Memory';
|
||||
const cache_in_memory_gzip = 'MemoryGZip';
|
||||
const cache_in_memory_serialized = 'MemorySerialized';
|
||||
const cache_igbinary = 'Igbinary';
|
||||
const cache_to_discISAM = 'DiscISAM';
|
||||
const cache_to_apc = 'APC';
|
||||
const cache_to_memcache = 'Memcache';
|
||||
const cache_to_phpTemp = 'PHPTemp';
|
||||
const cache_to_wincache = 'Wincache';
|
||||
const cache_to_sqlite = 'SQLite';
|
||||
const cache_to_sqlite3 = 'SQLite3';
|
||||
|
||||
|
||||
/**
|
||||
* Name of the method used for cell cacheing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_cacheStorageMethod = NULL;
|
||||
|
||||
/**
|
||||
* Name of the class used for cell cacheing
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_cacheStorageClass = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* List of all possible cache storage methods
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private static $_storageMethods = array(
|
||||
self::cache_in_memory,
|
||||
self::cache_in_memory_gzip,
|
||||
self::cache_in_memory_serialized,
|
||||
self::cache_igbinary,
|
||||
self::cache_to_phpTemp,
|
||||
self::cache_to_discISAM,
|
||||
self::cache_to_apc,
|
||||
self::cache_to_memcache,
|
||||
self::cache_to_wincache,
|
||||
self::cache_to_sqlite,
|
||||
self::cache_to_sqlite3,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Default arguments for each cache storage method
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
private static $_storageMethodDefaultParameters = array(
|
||||
self::cache_in_memory => array(
|
||||
),
|
||||
self::cache_in_memory_gzip => array(
|
||||
),
|
||||
self::cache_in_memory_serialized => array(
|
||||
),
|
||||
self::cache_igbinary => array(
|
||||
),
|
||||
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
||||
),
|
||||
self::cache_to_discISAM => array( 'dir' => NULL
|
||||
),
|
||||
self::cache_to_apc => array( 'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
|
||||
'memcachePort' => 11211,
|
||||
'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_wincache => array( 'cacheTime' => 600
|
||||
),
|
||||
self::cache_to_sqlite => array(
|
||||
),
|
||||
self::cache_to_sqlite3 => array(
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Arguments for the active cache storage method
|
||||
*
|
||||
* @var array of mixed array
|
||||
*/
|
||||
private static $_storageMethodParameters = array();
|
||||
|
||||
|
||||
/**
|
||||
* Return the current cache storage method
|
||||
*
|
||||
* @return string|NULL
|
||||
**/
|
||||
public static function getCacheStorageMethod()
|
||||
{
|
||||
return self::$_cacheStorageMethod;
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Return the current cache storage class
|
||||
*
|
||||
* @return PHPExcel_CachedObjectStorage_ICache|NULL
|
||||
**/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return self::$_cacheStorageClass;
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of all possible cache storage methods
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getAllCacheStorageMethods()
|
||||
{
|
||||
return self::$_storageMethods;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of all available cache storage methods
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getCacheStorageMethods()
|
||||
{
|
||||
$activeMethods = array();
|
||||
foreach(self::$_storageMethods as $storageMethod) {
|
||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
|
||||
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
|
||||
$activeMethods[] = $storageMethod;
|
||||
}
|
||||
}
|
||||
return $activeMethods;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
/**
|
||||
* Identify the cache storage method to use
|
||||
*
|
||||
* @param string $method Name of the method to use for cell cacheing
|
||||
* @param array of mixed $arguments Additional arguments to pass to the cell caching class
|
||||
* when instantiating
|
||||
* @return boolean
|
||||
**/
|
||||
public static function initialize($method = self::cache_in_memory, $arguments = array())
|
||||
{
|
||||
if (!in_array($method,self::$_storageMethods)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||
if (!call_user_func(array( $cacheStorageClass,
|
||||
'cacheMethodIsAvailable'))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
||||
foreach($arguments as $k => $v) {
|
||||
if (array_key_exists($k, self::$_storageMethodParameters[$method])) {
|
||||
self::$_storageMethodParameters[$method][$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$_cacheStorageMethod === NULL) {
|
||||
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
|
||||
self::$_cacheStorageMethod = $method;
|
||||
}
|
||||
return TRUE;
|
||||
} // function initialize()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the cache storage
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
|
||||
* @return PHPExcel_CachedObjectStorage_ICache
|
||||
**/
|
||||
public static function getInstance(PHPExcel_Worksheet $parent)
|
||||
{
|
||||
$cacheMethodIsAvailable = TRUE;
|
||||
if (self::$_cacheStorageMethod === NULL) {
|
||||
$cacheMethodIsAvailable = self::initialize();
|
||||
}
|
||||
|
||||
if ($cacheMethodIsAvailable) {
|
||||
$instance = new self::$_cacheStorageClass( $parent,
|
||||
self::$_storageMethodParameters[self::$_cacheStorageMethod]
|
||||
);
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} // function getInstance()
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,725 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Database
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Database {
|
||||
|
||||
|
||||
/**
|
||||
* __fieldExtract
|
||||
*
|
||||
* Extracts the column ID to use for the data field.
|
||||
*
|
||||
* @access private
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param mixed $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @return string|NULL
|
||||
*
|
||||
*/
|
||||
private static function __fieldExtract($database,$field) {
|
||||
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
|
||||
$fieldNames = array_map('strtoupper',array_shift($database));
|
||||
|
||||
if (is_numeric($field)) {
|
||||
$keys = array_keys($fieldNames);
|
||||
return $keys[$field-1];
|
||||
}
|
||||
$key = array_search($field,$fieldNames);
|
||||
return ($key) ? $key : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* __filter
|
||||
*
|
||||
* Parses the selection criteria, extracts the database rows that match those criteria, and
|
||||
* returns that subset of rows.
|
||||
*
|
||||
* @access private
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return array of mixed
|
||||
*
|
||||
*/
|
||||
private static function __filter($database,$criteria) {
|
||||
$fieldNames = array_shift($database);
|
||||
$criteriaNames = array_shift($criteria);
|
||||
|
||||
// Convert the criteria into a set of AND/OR conditions with [:placeholders]
|
||||
$testConditions = $testValues = array();
|
||||
$testConditionsCount = 0;
|
||||
foreach($criteriaNames as $key => $criteriaName) {
|
||||
$testCondition = array();
|
||||
$testConditionCount = 0;
|
||||
foreach($criteria as $row => $criterion) {
|
||||
if ($criterion[$key] > '') {
|
||||
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]);
|
||||
$testConditionCount++;
|
||||
}
|
||||
}
|
||||
if ($testConditionCount > 1) {
|
||||
$testConditions[] = 'OR('.implode(',',$testCondition).')';
|
||||
$testConditionsCount++;
|
||||
} elseif($testConditionCount == 1) {
|
||||
$testConditions[] = $testCondition[0];
|
||||
$testConditionsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($testConditionsCount > 1) {
|
||||
$testConditionSet = 'AND('.implode(',',$testConditions).')';
|
||||
} elseif($testConditionsCount == 1) {
|
||||
$testConditionSet = $testConditions[0];
|
||||
}
|
||||
|
||||
// Loop through each row of the database
|
||||
foreach($database as $dataRow => $dataValues) {
|
||||
// Substitute actual values from the database row for our [:placeholders]
|
||||
$testConditionList = $testConditionSet;
|
||||
foreach($criteriaNames as $key => $criteriaName) {
|
||||
$k = array_search($criteriaName,$fieldNames);
|
||||
if (isset($dataValues[$k])) {
|
||||
$dataValue = $dataValues[$k];
|
||||
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue;
|
||||
$testConditionList = str_replace('[:'.$criteriaName.']',$dataValue,$testConditionList);
|
||||
}
|
||||
}
|
||||
// evaluate the criteria against the row data
|
||||
$result = PHPExcel_Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList);
|
||||
// If the row failed to meet the criteria, remove it from the database
|
||||
if (!$result) {
|
||||
unset($database[$dataRow]);
|
||||
}
|
||||
}
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DAVERAGE
|
||||
*
|
||||
* Averages the values in a column of a list or database that match conditions you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DAVERAGE(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DAVERAGE($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::AVERAGE($colData);
|
||||
} // function DAVERAGE()
|
||||
|
||||
|
||||
/**
|
||||
* DCOUNT
|
||||
*
|
||||
* Counts the cells that contain numbers in a column of a list or database that match conditions
|
||||
* that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DCOUNT(database,[field],criteria)
|
||||
*
|
||||
* Excel Function:
|
||||
* DAVERAGE(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return integer
|
||||
*
|
||||
* @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
|
||||
* database that match the criteria.
|
||||
*
|
||||
*/
|
||||
public static function DCOUNT($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::COUNT($colData);
|
||||
} // function DCOUNT()
|
||||
|
||||
|
||||
/**
|
||||
* DCOUNTA
|
||||
*
|
||||
* Counts the nonblank cells in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DCOUNTA(database,[field],criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return integer
|
||||
*
|
||||
* @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the
|
||||
* database that match the criteria.
|
||||
*
|
||||
*/
|
||||
public static function DCOUNTA($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::COUNTA($colData);
|
||||
} // function DCOUNTA()
|
||||
|
||||
|
||||
/**
|
||||
* DGET
|
||||
*
|
||||
* Extracts a single value from a column of a list or database that matches conditions that you
|
||||
* specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DGET(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return mixed
|
||||
*
|
||||
*/
|
||||
public static function DGET($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
if (count($colData) > 1) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
|
||||
return $colData[0];
|
||||
} // function DGET()
|
||||
|
||||
|
||||
/**
|
||||
* DMAX
|
||||
*
|
||||
* Returns the largest number in a column of a list or database that matches conditions you that
|
||||
* specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DMAX(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DMAX($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::MAX($colData);
|
||||
} // function DMAX()
|
||||
|
||||
|
||||
/**
|
||||
* DMIN
|
||||
*
|
||||
* Returns the smallest number in a column of a list or database that matches conditions you that
|
||||
* specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DMIN(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DMIN($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::MIN($colData);
|
||||
} // function DMIN()
|
||||
|
||||
|
||||
/**
|
||||
* DPRODUCT
|
||||
*
|
||||
* Multiplies the values in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DPRODUCT(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DPRODUCT($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_MathTrig::PRODUCT($colData);
|
||||
} // function DPRODUCT()
|
||||
|
||||
|
||||
/**
|
||||
* DSTDEV
|
||||
*
|
||||
* Estimates the standard deviation of a population based on a sample by using the numbers in a
|
||||
* column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DSTDEV(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSTDEV($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::STDEV($colData);
|
||||
} // function DSTDEV()
|
||||
|
||||
|
||||
/**
|
||||
* DSTDEVP
|
||||
*
|
||||
* Calculates the standard deviation of a population based on the entire population by using the
|
||||
* numbers in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DSTDEVP(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSTDEVP($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::STDEVP($colData);
|
||||
} // function DSTDEVP()
|
||||
|
||||
|
||||
/**
|
||||
* DSUM
|
||||
*
|
||||
* Adds the numbers in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DSUM(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DSUM($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_MathTrig::SUM($colData);
|
||||
} // function DSUM()
|
||||
|
||||
|
||||
/**
|
||||
* DVAR
|
||||
*
|
||||
* Estimates the variance of a population based on a sample by using the numbers in a column
|
||||
* of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DVAR(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DVAR($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::VARFunc($colData);
|
||||
} // function DVAR()
|
||||
|
||||
|
||||
/**
|
||||
* DVARP
|
||||
*
|
||||
* Calculates the variance of a population based on the entire population by using the numbers
|
||||
* in a column of a list or database that match conditions that you specify.
|
||||
*
|
||||
* Excel Function:
|
||||
* DVARP(database,field,criteria)
|
||||
*
|
||||
* @access public
|
||||
* @category Database Functions
|
||||
* @param mixed[] $database The range of cells that makes up the list or database.
|
||||
* A database is a list of related data in which rows of related
|
||||
* information are records, and columns of data are fields. The
|
||||
* first row of the list contains labels for each column.
|
||||
* @param string|integer $field Indicates which column is used in the function. Enter the
|
||||
* column label enclosed between double quotation marks, such as
|
||||
* "Age" or "Yield," or a number (without quotation marks) that
|
||||
* represents the position of the column within the list: 1 for
|
||||
* the first column, 2 for the second column, and so on.
|
||||
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
|
||||
* You can use any range for the criteria argument, as long as it
|
||||
* includes at least one column label and at least one cell below
|
||||
* the column label in which you specify a condition for the
|
||||
* column.
|
||||
* @return float
|
||||
*
|
||||
*/
|
||||
public static function DVARP($database,$field,$criteria) {
|
||||
$field = self::__fieldExtract($database,$field);
|
||||
if (is_null($field)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// reduce the database to a set of rows that match all the criteria
|
||||
$database = self::__filter($database,$criteria);
|
||||
// extract an array of values for the requested column
|
||||
$colData = array();
|
||||
foreach($database as $row) {
|
||||
$colData[] = $row[$field];
|
||||
}
|
||||
|
||||
// Return
|
||||
return PHPExcel_Calculation_Statistical::VARP($colData);
|
||||
} // function DVARP()
|
||||
|
||||
|
||||
} // class PHPExcel_Calculation_Database
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Exception extends Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_ExceptionHandler
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_ExceptionHandler {
|
||||
/**
|
||||
* Register errorhandler
|
||||
*/
|
||||
public function __construct() {
|
||||
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister errorhandler
|
||||
*/
|
||||
public function __destruct() {
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,614 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or implied, including but not
|
||||
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
|
||||
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
|
||||
software or the use or other dealings in the software.
|
||||
|
||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_FormulaParser
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_FormulaParser {
|
||||
/* Character constants */
|
||||
const QUOTE_DOUBLE = '"';
|
||||
const QUOTE_SINGLE = '\'';
|
||||
const BRACKET_CLOSE = ']';
|
||||
const BRACKET_OPEN = '[';
|
||||
const BRACE_OPEN = '{';
|
||||
const BRACE_CLOSE = '}';
|
||||
const PAREN_OPEN = '(';
|
||||
const PAREN_CLOSE = ')';
|
||||
const SEMICOLON = ';';
|
||||
const WHITESPACE = ' ';
|
||||
const COMMA = ',';
|
||||
const ERROR_START = '#';
|
||||
|
||||
const OPERATORS_SN = "+-";
|
||||
const OPERATORS_INFIX = "+-*/^&=><";
|
||||
const OPERATORS_POSTFIX = "%";
|
||||
|
||||
/**
|
||||
* Formula
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formula;
|
||||
|
||||
/**
|
||||
* Tokens
|
||||
*
|
||||
* @var PHPExcel_Calculation_FormulaToken[]
|
||||
*/
|
||||
private $_tokens = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_FormulaParser
|
||||
*
|
||||
* @param string $pFormula Formula to parse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pFormula = '')
|
||||
{
|
||||
// Check parameters
|
||||
if (is_null($pFormula)) {
|
||||
throw new Exception("Invalid parameter passed: formula");
|
||||
}
|
||||
|
||||
// Initialise values
|
||||
$this->_formula = trim($pFormula);
|
||||
// Parse!
|
||||
$this->_parseToTokens();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Formula
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula() {
|
||||
return $this->_formula;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token
|
||||
*
|
||||
* @param int $pId Token id
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getToken($pId = 0) {
|
||||
if (isset($this->_tokens[$pId])) {
|
||||
return $this->_tokens[$pId];
|
||||
} else {
|
||||
throw new Exception("Token with id $pId does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token count
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenCount() {
|
||||
return count($this->_tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tokens
|
||||
*
|
||||
* @return PHPExcel_Calculation_FormulaToken[]
|
||||
*/
|
||||
public function getTokens() {
|
||||
return $this->_tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse to tokens
|
||||
*/
|
||||
private function _parseToTokens() {
|
||||
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where
|
||||
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
|
||||
|
||||
// Check if the formula has a valid starting =
|
||||
$formulaLength = strlen($this->_formula);
|
||||
if ($formulaLength < 2 || $this->_formula{0} != '=') return;
|
||||
|
||||
// Helper variables
|
||||
$tokens1 = $tokens2 = $stack = array();
|
||||
$inString = $inPath = $inRange = $inError = false;
|
||||
$token = $previousToken = $nextToken = null;
|
||||
|
||||
$index = 1;
|
||||
$value = '';
|
||||
|
||||
$ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A");
|
||||
$COMPARATORS_MULTI = array(">=", "<=", "<>");
|
||||
|
||||
while ($index < $formulaLength) {
|
||||
// state-dependent character evaluation (order is important)
|
||||
|
||||
// double-quoted strings
|
||||
// embeds are doubled
|
||||
// end marks token
|
||||
if ($inString) {
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
|
||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
|
||||
++$index;
|
||||
} else {
|
||||
$inString = false;
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_TEXT);
|
||||
$value = "";
|
||||
}
|
||||
} else {
|
||||
$value .= $this->_formula{$index};
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// single-quoted strings (links)
|
||||
// embeds are double
|
||||
// end does not mark a token
|
||||
if ($inPath) {
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
|
||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
|
||||
++$index;
|
||||
} else {
|
||||
$inPath = false;
|
||||
}
|
||||
} else {
|
||||
$value .= $this->_formula{$index};
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// bracked strings (R1C1 range index or linked workbook name)
|
||||
// no embeds (changed to "()" by Excel)
|
||||
// end does not mark a token
|
||||
if ($inRange) {
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
||||
$inRange = false;
|
||||
}
|
||||
$value .= $this->_formula{$index};
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// error values
|
||||
// end marks a token, determined from absolute list of values
|
||||
if ($inError) {
|
||||
$value .= $this->_formula{$index};
|
||||
++$index;
|
||||
if (in_array($value, $ERRORS)) {
|
||||
$inError = false;
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_ERROR);
|
||||
$value = "";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// scientific notation check
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->_formula{$index}) !== false) {
|
||||
if (strlen($value) > 1) {
|
||||
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->_formula{$index}) != 0) {
|
||||
$value .= $this->_formula{$index};
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// independent character evaluation (order not important)
|
||||
|
||||
// establish state-dependent character evaluations
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if (strlen($value > 0)) { // unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
$inString = true;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if (strlen($value) > 0) { // unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
$inPath = true;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
||||
$inRange = true;
|
||||
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
||||
if (strlen($value) > 0) { // unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
$inError = true;
|
||||
$value .= PHPExcel_Calculation_FormulaParser::ERROR_START;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// mark start and end of arrays and array rows
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
||||
if (strlen($value) > 0) { // unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAY", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// trim white-space
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
|
||||
++$index;
|
||||
while (($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
||||
++$index;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// multi-character comparators
|
||||
if (($index + 2) <= $formulaLength) {
|
||||
if (in_array(substr($this->_formula, $index, 2), $COMPARATORS_MULTI)) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->_formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
$index += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// standard infix operators
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// standard postfix operators (only one)
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->_formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// start subexpression or function
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
|
||||
if (strlen($value) > 0) {
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
$value = "";
|
||||
} else {
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
$stack[] = clone $tmp;
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// function, subexpression, or array parameters, or operand unions
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$stack[] = $tmp;
|
||||
|
||||
if ($tmp->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_UNION);
|
||||
} else {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// stop subexpression
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
|
||||
$tmp = array_pop($stack);
|
||||
$tmp->setValue("");
|
||||
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
|
||||
$tokens1[] = $tmp;
|
||||
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// token accumulation
|
||||
$value .= $this->_formula{$index};
|
||||
++$index;
|
||||
}
|
||||
|
||||
// dump remaining accumulation
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
}
|
||||
|
||||
// move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections
|
||||
$tokenCount = count($tokens1);
|
||||
for ($i = 0; $i < $tokenCount; ++$i) {
|
||||
$token = $tokens1[$i];
|
||||
if (isset($tokens1[$i - 1])) {
|
||||
$previousToken = $tokens1[$i - 1];
|
||||
} else {
|
||||
$previousToken = null;
|
||||
}
|
||||
if (isset($tokens1[$i + 1])) {
|
||||
$nextToken = $tokens1[$i + 1];
|
||||
} else {
|
||||
$nextToken = null;
|
||||
}
|
||||
|
||||
if (is_null($token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() != PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE) {
|
||||
$tokens2[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($previousToken)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! (
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($nextToken)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! (
|
||||
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
|
||||
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
|
||||
($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tokens2[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_INTERSECTION);
|
||||
}
|
||||
|
||||
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
|
||||
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
|
||||
$this->_tokens = array();
|
||||
|
||||
$tokenCount = count($tokens2);
|
||||
for ($i = 0; $i < $tokenCount; ++$i) {
|
||||
$token = $tokens2[$i];
|
||||
if (isset($tokens2[$i - 1])) {
|
||||
$previousToken = $tokens2[$i - 1];
|
||||
} else {
|
||||
$previousToken = null;
|
||||
}
|
||||
if (isset($tokens2[$i + 1])) {
|
||||
$nextToken = $tokens2[$i + 1];
|
||||
} else {
|
||||
$nextToken = null;
|
||||
}
|
||||
|
||||
if (is_null($token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
|
||||
if ($i == 0) {
|
||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
} else if (
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
|
||||
if ($i == 0) {
|
||||
continue;
|
||||
} else if (
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} else if ($token->getValue() == "&") {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
|
||||
} else {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (!is_numeric($token->getValue())) {
|
||||
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} else {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_RANGE);
|
||||
}
|
||||
} else {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
|
||||
if (strlen($token->getValue() > 0)) {
|
||||
if (substr($token->getValue(), 0, 1) == "@") {
|
||||
$token->setValue(substr($token->getValue(), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or implied, including but not
|
||||
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
|
||||
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
|
||||
software or the use or other dealings in the software.
|
||||
|
||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_FormulaToken {
|
||||
/* Token types */
|
||||
const TOKEN_TYPE_NOOP = 'Noop';
|
||||
const TOKEN_TYPE_OPERAND = 'Operand';
|
||||
const TOKEN_TYPE_FUNCTION = 'Function';
|
||||
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
|
||||
const TOKEN_TYPE_ARGUMENT = 'Argument';
|
||||
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
|
||||
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
|
||||
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
|
||||
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
|
||||
const TOKEN_TYPE_UNKNOWN = 'Unknown';
|
||||
|
||||
/* Token subtypes */
|
||||
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
|
||||
const TOKEN_SUBTYPE_START = 'Start';
|
||||
const TOKEN_SUBTYPE_STOP = 'Stop';
|
||||
const TOKEN_SUBTYPE_TEXT = 'Text';
|
||||
const TOKEN_SUBTYPE_NUMBER = 'Number';
|
||||
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
|
||||
const TOKEN_SUBTYPE_ERROR = 'Error';
|
||||
const TOKEN_SUBTYPE_RANGE = 'Range';
|
||||
const TOKEN_SUBTYPE_MATH = 'Math';
|
||||
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
|
||||
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
|
||||
const TOKEN_SUBTYPE_UNION = 'Union';
|
||||
|
||||
/**
|
||||
* Value
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_value;
|
||||
|
||||
/**
|
||||
* Token Type (represented by TOKEN_TYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tokenType;
|
||||
|
||||
/**
|
||||
* Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tokenSubType;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
|
||||
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
|
||||
*/
|
||||
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||
{
|
||||
// Initialise values
|
||||
$this->_value = $pValue;
|
||||
$this->_tokenType = $pTokenType;
|
||||
$this->_tokenSubType = $pTokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue() {
|
||||
return $this->_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Value
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value) {
|
||||
$this->_value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token Type (represented by TOKEN_TYPE_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenType() {
|
||||
return $this->_tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Token Type
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
|
||||
$this->_tokenType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenSubType() {
|
||||
return $this->_tokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Token SubType
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
$this->_tokenSubType = $value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Function
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Function {
|
||||
/* Function categories */
|
||||
const CATEGORY_CUBE = 'Cube';
|
||||
const CATEGORY_DATABASE = 'Database';
|
||||
const CATEGORY_DATE_AND_TIME = 'Date and Time';
|
||||
const CATEGORY_ENGINEERING = 'Engineering';
|
||||
const CATEGORY_FINANCIAL = 'Financial';
|
||||
const CATEGORY_INFORMATION = 'Information';
|
||||
const CATEGORY_LOGICAL = 'Logical';
|
||||
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
|
||||
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
|
||||
const CATEGORY_STATISTICAL = 'Statistical';
|
||||
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
|
||||
|
||||
/**
|
||||
* Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category;
|
||||
|
||||
/**
|
||||
* Excel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_excelName;
|
||||
|
||||
/**
|
||||
* PHPExcel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_phpExcelName;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_Function
|
||||
*
|
||||
* @param string $pCategory Category (represented by CATEGORY_*)
|
||||
* @param string $pExcelName Excel function name
|
||||
* @param string $pPHPExcelName PHPExcel function mapping
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL)
|
||||
{
|
||||
if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) {
|
||||
// Initialise values
|
||||
$this->_category = $pCategory;
|
||||
$this->_excelName = $pExcelName;
|
||||
$this->_phpExcelName = $pPHPExcelName;
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category (represented by CATEGORY_*)
|
||||
*
|
||||
* @param string $value
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setCategory($value = null) {
|
||||
if (!is_null($value)) {
|
||||
$this->_category = $value;
|
||||
} else {
|
||||
throw new Exception("Invalid parameter passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Excel name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExcelName() {
|
||||
return $this->_excelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Excel name
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setExcelName($value) {
|
||||
$this->_excelName = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPHPExcelName() {
|
||||
return $this->_phpExcelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PHPExcel name
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setPHPExcelName($value) {
|
||||
$this->_phpExcelName = $value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Logical
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Logical {
|
||||
|
||||
/**
|
||||
* TRUE
|
||||
*
|
||||
* Returns the boolean TRUE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =TRUE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean True
|
||||
*/
|
||||
public static function TRUE() {
|
||||
return TRUE;
|
||||
} // function TRUE()
|
||||
|
||||
|
||||
/**
|
||||
* FALSE
|
||||
*
|
||||
* Returns the boolean FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =FALSE()
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @return boolean False
|
||||
*/
|
||||
public static function FALSE() {
|
||||
return FALSE;
|
||||
} // function FALSE()
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_AND
|
||||
*
|
||||
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =AND(logical1[,logical2[, ...]])
|
||||
*
|
||||
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
||||
* or references that contain logical values.
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical AND of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_AND() {
|
||||
// Return value
|
||||
$returnValue = TRUE;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
if (is_bool($arg)) {
|
||||
$returnValue = $returnValue && $arg;
|
||||
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue = $returnValue && ($arg != 0);
|
||||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = TRUE;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = FALSE;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue && ($arg != 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
} // function LOGICAL_AND()
|
||||
|
||||
|
||||
/**
|
||||
* LOGICAL_OR
|
||||
*
|
||||
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =OR(logical1[,logical2[, ...]])
|
||||
*
|
||||
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
||||
* or references that contain logical values.
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical OR of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_OR() {
|
||||
// Return value
|
||||
$returnValue = FALSE;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
if (is_bool($arg)) {
|
||||
$returnValue = $returnValue || $arg;
|
||||
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue = $returnValue || ($arg != 0);
|
||||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = TRUE;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = FALSE;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue || ($arg != 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
} // function LOGICAL_OR()
|
||||
|
||||
|
||||
/**
|
||||
* NOT
|
||||
*
|
||||
* Returns the boolean inverse of the argument.
|
||||
*
|
||||
* Excel Function:
|
||||
* =NOT(logical)
|
||||
*
|
||||
* The argument must evaluate to a logical value such as TRUE or FALSE
|
||||
*
|
||||
* Boolean arguments are treated as True or False as appropriate
|
||||
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
||||
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
|
||||
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
||||
* @return boolean The boolean inverse of the argument.
|
||||
*/
|
||||
public static function NOT($logical=FALSE) {
|
||||
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
||||
if (is_string($logical)) {
|
||||
$logical = strtoupper($logical);
|
||||
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
||||
return FALSE;
|
||||
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
return !$logical;
|
||||
} // function NOT()
|
||||
|
||||
/**
|
||||
* STATEMENT_IF
|
||||
*
|
||||
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
|
||||
*
|
||||
* Excel Function:
|
||||
* =IF(condition[,returnIfTrue[,returnIfFalse]])
|
||||
*
|
||||
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
|
||||
* For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
|
||||
* the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
|
||||
* This argument can use any comparison calculation operator.
|
||||
* ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
|
||||
* For example, if this argument is the text string "Within budget" and the condition argument evaluates to TRUE,
|
||||
* then the IF function returns the text "Within budget"
|
||||
* If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero). To display the word TRUE, use
|
||||
* the logical value TRUE for this argument.
|
||||
* ReturnIfTrue can be another formula.
|
||||
* ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
|
||||
* For example, if this argument is the text string "Over budget" and the condition argument evaluates to FALSE,
|
||||
* then the IF function returns the text "Over budget".
|
||||
* If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
|
||||
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
|
||||
* ReturnIfFalse can be another formula.
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $condition Condition to evaluate
|
||||
* @param mixed $returnIfTrue Value to return when condition is true
|
||||
* @param mixed $returnIfFalse Optional value to return when condition is false
|
||||
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
||||
*/
|
||||
public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
|
||||
$condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
|
||||
$returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
||||
|
||||
return ($condition) ? $returnIfTrue : $returnIfFalse;
|
||||
} // function STATEMENT_IF()
|
||||
|
||||
|
||||
/**
|
||||
* IFERROR
|
||||
*
|
||||
* Excel Function:
|
||||
* =IFERROR(testValue,errorpart)
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param mixed $testValue Value to check, is also the value returned when no error
|
||||
* @param mixed $errorpart Value to return when testValue is an error condition
|
||||
* @return mixed The value of errorpart or testValue determined by error condition
|
||||
*/
|
||||
public static function IFERROR($testValue = '', $errorpart = '') {
|
||||
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
|
||||
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
|
||||
|
||||
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
|
||||
} // function IFERROR()
|
||||
|
||||
} // class PHPExcel_Calculation_Logical
|
|
@ -0,0 +1,808 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_LookupRef
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_LookupRef {
|
||||
|
||||
|
||||
/**
|
||||
* CELL_ADDRESS
|
||||
*
|
||||
* Creates a cell address as text, given specified row and column numbers.
|
||||
*
|
||||
* Excel Function:
|
||||
* =ADDRESS(row, column, [relativity], [referenceStyle], [sheetText])
|
||||
*
|
||||
* @param row Row number to use in the cell reference
|
||||
* @param column Column number to use in the cell reference
|
||||
* @param relativity Flag indicating the type of reference to return
|
||||
* 1 or omitted Absolute
|
||||
* 2 Absolute row; relative column
|
||||
* 3 Relative row; absolute column
|
||||
* 4 Relative
|
||||
* @param referenceStyle A logical value that specifies the A1 or R1C1 reference style.
|
||||
* TRUE or omitted CELL_ADDRESS returns an A1-style reference
|
||||
* FALSE CELL_ADDRESS returns an R1C1-style reference
|
||||
* @param sheetText Optional Name of worksheet to use
|
||||
* @return string
|
||||
*/
|
||||
public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') {
|
||||
$row = PHPExcel_Calculation_Functions::flattenSingleValue($row);
|
||||
$column = PHPExcel_Calculation_Functions::flattenSingleValue($column);
|
||||
$relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity);
|
||||
$sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText);
|
||||
|
||||
if (($row < 1) || ($column < 1)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if ($sheetText > '') {
|
||||
if (strpos($sheetText,' ') !== False) { $sheetText = "'".$sheetText."'"; }
|
||||
$sheetText .='!';
|
||||
}
|
||||
if ((!is_bool($referenceStyle)) || $referenceStyle) {
|
||||
$rowRelative = $columnRelative = '$';
|
||||
$column = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; }
|
||||
if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; }
|
||||
return $sheetText.$columnRelative.$column.$rowRelative.$row;
|
||||
} else {
|
||||
if (($relativity == 2) || ($relativity == 4)) { $column = '['.$column.']'; }
|
||||
if (($relativity == 3) || ($relativity == 4)) { $row = '['.$row.']'; }
|
||||
return $sheetText.'R'.$row.'C'.$column;
|
||||
}
|
||||
} // function CELL_ADDRESS()
|
||||
|
||||
|
||||
/**
|
||||
* COLUMN
|
||||
*
|
||||
* Returns the column number of the given cell reference
|
||||
* If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array.
|
||||
* If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
|
||||
* reference of the cell in which the COLUMN function appears; otherwise this function returns 0.
|
||||
*
|
||||
* Excel Function:
|
||||
* =COLUMN([cellAddress])
|
||||
*
|
||||
* @param cellAddress A reference to a range of cells for which you want the column numbers
|
||||
* @return integer or array of integer
|
||||
*/
|
||||
public static function COLUMN($cellAddress=Null) {
|
||||
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
|
||||
|
||||
if (is_array($cellAddress)) {
|
||||
foreach($cellAddress as $columnKey => $value) {
|
||||
$columnKey = preg_replace('/[^a-z]/i','',$columnKey);
|
||||
return (integer) PHPExcel_Cell::columnIndexFromString($columnKey);
|
||||
}
|
||||
} else {
|
||||
if (strpos($cellAddress,'!') !== false) {
|
||||
list($sheet,$cellAddress) = explode('!',$cellAddress);
|
||||
}
|
||||
if (strpos($cellAddress,':') !== false) {
|
||||
list($startAddress,$endAddress) = explode(':',$cellAddress);
|
||||
$startAddress = preg_replace('/[^a-z]/i','',$startAddress);
|
||||
$endAddress = preg_replace('/[^a-z]/i','',$endAddress);
|
||||
$returnValue = array();
|
||||
do {
|
||||
$returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress);
|
||||
} while ($startAddress++ != $endAddress);
|
||||
return $returnValue;
|
||||
} else {
|
||||
$cellAddress = preg_replace('/[^a-z]/i','',$cellAddress);
|
||||
return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress);
|
||||
}
|
||||
}
|
||||
} // function COLUMN()
|
||||
|
||||
|
||||
/**
|
||||
* COLUMNS
|
||||
*
|
||||
* Returns the number of columns in an array or reference.
|
||||
*
|
||||
* Excel Function:
|
||||
* =COLUMNS(cellAddress)
|
||||
*
|
||||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
|
||||
* @return integer The number of columns in cellAddress
|
||||
*/
|
||||
public static function COLUMNS($cellAddress=Null) {
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return 1;
|
||||
} elseif (!is_array($cellAddress)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
$x = array_keys($cellAddress);
|
||||
$x = array_shift($x);
|
||||
$isMatrix = (is_numeric($x));
|
||||
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||
|
||||
if ($isMatrix) {
|
||||
return $rows;
|
||||
} else {
|
||||
return $columns;
|
||||
}
|
||||
} // function COLUMNS()
|
||||
|
||||
|
||||
/**
|
||||
* ROW
|
||||
*
|
||||
* Returns the row number of the given cell reference
|
||||
* If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array.
|
||||
* If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
|
||||
* reference of the cell in which the ROW function appears; otherwise this function returns 0.
|
||||
*
|
||||
* Excel Function:
|
||||
* =ROW([cellAddress])
|
||||
*
|
||||
* @param cellAddress A reference to a range of cells for which you want the row numbers
|
||||
* @return integer or array of integer
|
||||
*/
|
||||
public static function ROW($cellAddress=Null) {
|
||||
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
|
||||
|
||||
if (is_array($cellAddress)) {
|
||||
foreach($cellAddress as $columnKey => $rowValue) {
|
||||
foreach($rowValue as $rowKey => $cellValue) {
|
||||
return (integer) preg_replace('/[^0-9]/i','',$rowKey);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (strpos($cellAddress,'!') !== false) {
|
||||
list($sheet,$cellAddress) = explode('!',$cellAddress);
|
||||
}
|
||||
if (strpos($cellAddress,':') !== false) {
|
||||
list($startAddress,$endAddress) = explode(':',$cellAddress);
|
||||
$startAddress = preg_replace('/[^0-9]/','',$startAddress);
|
||||
$endAddress = preg_replace('/[^0-9]/','',$endAddress);
|
||||
$returnValue = array();
|
||||
do {
|
||||
$returnValue[][] = (integer) $startAddress;
|
||||
} while ($startAddress++ != $endAddress);
|
||||
return $returnValue;
|
||||
} else {
|
||||
list($cellAddress) = explode(':',$cellAddress);
|
||||
return (integer) preg_replace('/[^0-9]/','',$cellAddress);
|
||||
}
|
||||
}
|
||||
} // function ROW()
|
||||
|
||||
|
||||
/**
|
||||
* ROWS
|
||||
*
|
||||
* Returns the number of rows in an array or reference.
|
||||
*
|
||||
* Excel Function:
|
||||
* =ROWS(cellAddress)
|
||||
*
|
||||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
|
||||
* @return integer The number of rows in cellAddress
|
||||
*/
|
||||
public static function ROWS($cellAddress=Null) {
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return 1;
|
||||
} elseif (!is_array($cellAddress)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
$i = array_keys($cellAddress);
|
||||
$isMatrix = (is_numeric(array_shift($i)));
|
||||
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||
|
||||
if ($isMatrix) {
|
||||
return $columns;
|
||||
} else {
|
||||
return $rows;
|
||||
}
|
||||
} // function ROWS()
|
||||
|
||||
|
||||
/**
|
||||
* HYPERLINK
|
||||
*
|
||||
* Excel Function:
|
||||
* =HYPERLINK(linkURL,displayName)
|
||||
*
|
||||
* @access public
|
||||
* @category Logical Functions
|
||||
* @param string $linkURL Value to check, is also the value returned when no error
|
||||
* @param string $displayName Value to return when testValue is an error condition
|
||||
* @return mixed The value of $displayName (or $linkURL if $displayName was blank)
|
||||
*/
|
||||
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) {
|
||||
$args = func_get_args();
|
||||
$pCell = array_pop($args);
|
||||
|
||||
$linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL);
|
||||
$displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName);
|
||||
|
||||
if ((!is_object($pCell)) || (trim($linkURL) == '')) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
if ((is_object($displayName)) || trim($displayName) == '') {
|
||||
$displayName = $linkURL;
|
||||
}
|
||||
|
||||
$pCell->getHyperlink()->setUrl($linkURL);
|
||||
|
||||
return $displayName;
|
||||
} // function HYPERLINK()
|
||||
|
||||
|
||||
/**
|
||||
* INDIRECT
|
||||
*
|
||||
* Returns the reference specified by a text string.
|
||||
* References are immediately evaluated to display their contents.
|
||||
*
|
||||
* Excel Function:
|
||||
* =INDIRECT(cellAddress)
|
||||
*
|
||||
* NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010
|
||||
*
|
||||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
|
||||
* @return mixed The cells referenced by cellAddress
|
||||
*
|
||||
* @todo Support for the optional a1 parameter introduced in Excel 2010
|
||||
*
|
||||
*/
|
||||
public static function INDIRECT($cellAddress=Null, PHPExcel_Cell $pCell = null) {
|
||||
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
$cellAddress1 = $cellAddress;
|
||||
$cellAddress2 = NULL;
|
||||
if (strpos($cellAddress,':') !== false) {
|
||||
list($cellAddress1,$cellAddress2) = explode(':',$cellAddress);
|
||||
}
|
||||
|
||||
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
|
||||
((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) {
|
||||
|
||||
if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
if (strpos($cellAddress,'!') !== false) {
|
||||
list($sheetName,$cellAddress) = explode('!',$cellAddress);
|
||||
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getParent();
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, False);
|
||||
}
|
||||
|
||||
if (strpos($cellAddress,'!') !== false) {
|
||||
list($sheetName,$cellAddress) = explode('!',$cellAddress);
|
||||
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getParent();
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
|
||||
} // function INDIRECT()
|
||||
|
||||
|
||||
/**
|
||||
* OFFSET
|
||||
*
|
||||
* Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells.
|
||||
* The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and
|
||||
* the number of columns to be returned.
|
||||
*
|
||||
* Excel Function:
|
||||
* =OFFSET(cellAddress, rows, cols, [height], [width])
|
||||
*
|
||||
* @param cellAddress The reference from which you want to base the offset. Reference must refer to a cell or
|
||||
* range of adjacent cells; otherwise, OFFSET returns the #VALUE! error value.
|
||||
* @param rows The number of rows, up or down, that you want the upper-left cell to refer to.
|
||||
* Using 5 as the rows argument specifies that the upper-left cell in the reference is
|
||||
* five rows below reference. Rows can be positive (which means below the starting reference)
|
||||
* or negative (which means above the starting reference).
|
||||
* @param cols The number of columns, to the left or right, that you want the upper-left cell of the result
|
||||
* to refer to. Using 5 as the cols argument specifies that the upper-left cell in the
|
||||
* reference is five columns to the right of reference. Cols can be positive (which means
|
||||
* to the right of the starting reference) or negative (which means to the left of the
|
||||
* starting reference).
|
||||
* @param height The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
|
||||
* @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
|
||||
* @return string A reference to a cell or range of cells
|
||||
*/
|
||||
public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) {
|
||||
$rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows);
|
||||
$columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns);
|
||||
$height = PHPExcel_Calculation_Functions::flattenSingleValue($height);
|
||||
$width = PHPExcel_Calculation_Functions::flattenSingleValue($width);
|
||||
if ($cellAddress == Null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$args = func_get_args();
|
||||
$pCell = array_pop($args);
|
||||
if (!is_object($pCell)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
$sheetName = null;
|
||||
if (strpos($cellAddress,"!")) {
|
||||
list($sheetName,$cellAddress) = explode("!",$cellAddress);
|
||||
}
|
||||
if (strpos($cellAddress,":")) {
|
||||
list($startCell,$endCell) = explode(":",$cellAddress);
|
||||
} else {
|
||||
$startCell = $endCell = $cellAddress;
|
||||
}
|
||||
list($startCellColumn,$startCellRow) = PHPExcel_Cell::coordinateFromString($startCell);
|
||||
list($endCellColumn,$endCellRow) = PHPExcel_Cell::coordinateFromString($endCell);
|
||||
|
||||
$startCellRow += $rows;
|
||||
$startCellColumn = PHPExcel_Cell::columnIndexFromString($startCellColumn) - 1;
|
||||
$startCellColumn += $columns;
|
||||
|
||||
if (($startCellRow <= 0) || ($startCellColumn < 0)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
$endCellColumn = PHPExcel_Cell::columnIndexFromString($endCellColumn) - 1;
|
||||
if (($width != null) && (!is_object($width))) {
|
||||
$endCellColumn = $startCellColumn + $width - 1;
|
||||
} else {
|
||||
$endCellColumn += $columns;
|
||||
}
|
||||
$startCellColumn = PHPExcel_Cell::stringFromColumnIndex($startCellColumn);
|
||||
|
||||
if (($height != null) && (!is_object($height))) {
|
||||
$endCellRow = $startCellRow + $height - 1;
|
||||
} else {
|
||||
$endCellRow += $rows;
|
||||
}
|
||||
|
||||
if (($endCellRow <= 0) || ($endCellColumn < 0)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
$endCellColumn = PHPExcel_Cell::stringFromColumnIndex($endCellColumn);
|
||||
|
||||
$cellAddress = $startCellColumn.$startCellRow;
|
||||
if (($startCellColumn != $endCellColumn) || ($startCellRow != $endCellRow)) {
|
||||
$cellAddress .= ':'.$endCellColumn.$endCellRow;
|
||||
}
|
||||
|
||||
if ($sheetName !== null) {
|
||||
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
|
||||
} else {
|
||||
$pSheet = $pCell->getParent();
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
|
||||
} // function OFFSET()
|
||||
|
||||
|
||||
/**
|
||||
* CHOOSE
|
||||
*
|
||||
* Uses lookup_value to return a value from the list of value arguments.
|
||||
* Use CHOOSE to select one of up to 254 values based on the lookup_value.
|
||||
*
|
||||
* Excel Function:
|
||||
* =CHOOSE(index_num, value1, [value2], ...)
|
||||
*
|
||||
* @param index_num Specifies which value argument is selected.
|
||||
* Index_num must be a number between 1 and 254, or a formula or reference to a cell containing a number
|
||||
* between 1 and 254.
|
||||
* @param value1... Value1 is required, subsequent values are optional.
|
||||
* Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on
|
||||
* index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or
|
||||
* text.
|
||||
* @return mixed The selected value
|
||||
*/
|
||||
public static function CHOOSE() {
|
||||
$chooseArgs = func_get_args();
|
||||
$chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs));
|
||||
$entryCount = count($chooseArgs) - 1;
|
||||
|
||||
if(is_array($chosenEntry)) {
|
||||
$chosenEntry = array_shift($chosenEntry);
|
||||
}
|
||||
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
|
||||
--$chosenEntry;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$chosenEntry = floor($chosenEntry);
|
||||
if (($chosenEntry <= 0) || ($chosenEntry > $entryCount)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_array($chooseArgs[$chosenEntry])) {
|
||||
return PHPExcel_Calculation_Functions::flattenArray($chooseArgs[$chosenEntry]);
|
||||
} else {
|
||||
return $chooseArgs[$chosenEntry];
|
||||
}
|
||||
} // function CHOOSE()
|
||||
|
||||
|
||||
/**
|
||||
* MATCH
|
||||
*
|
||||
* The MATCH function searches for a specified item in a range of cells
|
||||
*
|
||||
* Excel Function:
|
||||
* =MATCH(lookup_value, lookup_array, [match_type])
|
||||
*
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_array The range of cells being searched
|
||||
* @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
|
||||
* @return integer The relative position of the found item
|
||||
*/
|
||||
public static function MATCH($lookup_value, $lookup_array, $match_type=1) {
|
||||
$lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array);
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type);
|
||||
// MATCH is not case sensitive
|
||||
$lookup_value = strtolower($lookup_value);
|
||||
|
||||
// lookup_value type has to be number, text, or logical values
|
||||
if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
// match_type is 0, 1 or -1
|
||||
if (($match_type !== 0) && ($match_type !== -1) && ($match_type !== 1)) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should not be empty
|
||||
$lookupArraySize = count($lookup_array);
|
||||
if ($lookupArraySize <= 0) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should contain only number, text, or logical values, or empty (null) cells
|
||||
foreach($lookup_array as $i => $lookupArrayValue) {
|
||||
// check the type of the value
|
||||
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
|
||||
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
// convert strings to lowercase for case-insensitive testing
|
||||
if (is_string($lookupArrayValue)) {
|
||||
$lookup_array[$i] = strtolower($lookupArrayValue);
|
||||
}
|
||||
if ((is_null($lookupArrayValue)) && (($match_type == 1) || ($match_type == -1))) {
|
||||
$lookup_array = array_slice($lookup_array,0,$i-1);
|
||||
}
|
||||
}
|
||||
|
||||
// if match_type is 1 or -1, the list has to be ordered
|
||||
if ($match_type == 1) {
|
||||
asort($lookup_array);
|
||||
$keySet = array_keys($lookup_array);
|
||||
} elseif($match_type == -1) {
|
||||
arsort($lookup_array);
|
||||
$keySet = array_keys($lookup_array);
|
||||
}
|
||||
|
||||
// **
|
||||
// find the match
|
||||
// **
|
||||
// loop on the cells
|
||||
// var_dump($lookup_array);
|
||||
// echo '<br />';
|
||||
foreach($lookup_array as $i => $lookupArrayValue) {
|
||||
if (($match_type == 0) && ($lookupArrayValue == $lookup_value)) {
|
||||
// exact match
|
||||
return ++$i;
|
||||
} elseif (($match_type == -1) && ($lookupArrayValue <= $lookup_value)) {
|
||||
// echo '$i = '.$i.' => ';
|
||||
// var_dump($lookupArrayValue);
|
||||
// echo '<br />';
|
||||
// echo 'Keyset = ';
|
||||
// var_dump($keySet);
|
||||
// echo '<br />';
|
||||
$i = array_search($i,$keySet);
|
||||
// echo '$i='.$i.'<br />';
|
||||
// if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value
|
||||
if ($i < 1){
|
||||
// 1st cell was allready smaller than the lookup_value
|
||||
break;
|
||||
} else {
|
||||
// the previous cell was the match
|
||||
return $keySet[$i-1]+1;
|
||||
}
|
||||
} elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) {
|
||||
// echo '$i = '.$i.' => ';
|
||||
// var_dump($lookupArrayValue);
|
||||
// echo '<br />';
|
||||
// echo 'Keyset = ';
|
||||
// var_dump($keySet);
|
||||
// echo '<br />';
|
||||
$i = array_search($i,$keySet);
|
||||
// echo '$i='.$i.'<br />';
|
||||
// if match_type is 1 <=> find the largest value that is less than or equal to lookup_value
|
||||
if ($i < 1){
|
||||
// 1st cell was allready bigger than the lookup_value
|
||||
break;
|
||||
} else {
|
||||
// the previous cell was the match
|
||||
return $keySet[$i-1]+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unsuccessful in finding a match, return #N/A error value
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
} // function MATCH()
|
||||
|
||||
|
||||
/**
|
||||
* INDEX
|
||||
*
|
||||
* Uses an index to choose a value from a reference or array
|
||||
*
|
||||
* Excel Function:
|
||||
* =INDEX(range_array, row_num, [column_num])
|
||||
*
|
||||
* @param range_array A range of cells or an array constant
|
||||
* @param row_num The row in array from which to return a value. If row_num is omitted, column_num is required.
|
||||
* @param column_num The column in array from which to return a value. If column_num is omitted, row_num is required.
|
||||
* @return mixed the value of a specified cell or array of cells
|
||||
*/
|
||||
public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) {
|
||||
|
||||
if (($rowNum < 0) || ($columnNum < 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (!is_array($arrayValues)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
}
|
||||
|
||||
$rowKeys = array_keys($arrayValues);
|
||||
$columnKeys = @array_keys($arrayValues[$rowKeys[0]]);
|
||||
|
||||
if ($columnNum > count($columnKeys)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($columnNum == 0) {
|
||||
if ($rowNum == 0) {
|
||||
return $arrayValues;
|
||||
}
|
||||
$rowNum = $rowKeys[--$rowNum];
|
||||
$returnArray = array();
|
||||
foreach($arrayValues as $arrayColumn) {
|
||||
if (is_array($arrayColumn)) {
|
||||
if (isset($arrayColumn[$rowNum])) {
|
||||
$returnArray[] = $arrayColumn[$rowNum];
|
||||
} else {
|
||||
return $arrayValues[$rowNum];
|
||||
}
|
||||
} else {
|
||||
return $arrayValues[$rowNum];
|
||||
}
|
||||
}
|
||||
return $returnArray;
|
||||
}
|
||||
$columnNum = $columnKeys[--$columnNum];
|
||||
if ($rowNum > count($rowKeys)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($rowNum == 0) {
|
||||
return $arrayValues[$columnNum];
|
||||
}
|
||||
$rowNum = $rowKeys[--$rowNum];
|
||||
|
||||
return $arrayValues[$rowNum][$columnNum];
|
||||
} // function INDEX()
|
||||
|
||||
|
||||
/**
|
||||
* TRANSPOSE
|
||||
*
|
||||
* @param array $matrixData A matrix of values
|
||||
* @return array
|
||||
*
|
||||
* Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix.
|
||||
*/
|
||||
public static function TRANSPOSE($matrixData) {
|
||||
$returnMatrix = array();
|
||||
if (!is_array($matrixData)) { $matrixData = array(array($matrixData)); }
|
||||
|
||||
$column = 0;
|
||||
foreach($matrixData as $matrixRow) {
|
||||
$row = 0;
|
||||
foreach($matrixRow as $matrixCell) {
|
||||
$returnMatrix[$row][$column] = $matrixCell;
|
||||
++$row;
|
||||
}
|
||||
++$column;
|
||||
}
|
||||
return $returnMatrix;
|
||||
} // function TRANSPOSE()
|
||||
|
||||
|
||||
private static function _vlookupSort($a,$b) {
|
||||
$f = array_keys($a);
|
||||
$firstColumn = array_shift($f);
|
||||
if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
|
||||
return 0;
|
||||
}
|
||||
return (strtolower($a[$firstColumn]) < strtolower($b[$firstColumn])) ? -1 : 1;
|
||||
} // function _vlookupSort()
|
||||
|
||||
|
||||
/**
|
||||
* VLOOKUP
|
||||
* The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number.
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_array The range of cells being searched
|
||||
* @param index_number The column number in table_array from which the matching value must be returned. The first column is 1.
|
||||
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value.
|
||||
* @return mixed The value of the found cell
|
||||
*/
|
||||
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) {
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
|
||||
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
|
||||
|
||||
// index_number must be greater than or equal to 1
|
||||
if ($index_number < 1) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
// index_number must be less than or equal to the number of columns in lookup_array
|
||||
if ((!is_array($lookup_array)) || (empty($lookup_array))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
} else {
|
||||
$f = array_keys($lookup_array);
|
||||
$firstRow = array_pop($f);
|
||||
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
} else {
|
||||
$columnKeys = array_keys($lookup_array[$firstRow]);
|
||||
$returnColumn = $columnKeys[--$index_number];
|
||||
$firstColumn = array_shift($columnKeys);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$not_exact_match) {
|
||||
uasort($lookup_array,array('self','_vlookupSort'));
|
||||
}
|
||||
|
||||
$rowNumber = $rowValue = False;
|
||||
foreach($lookup_array as $rowKey => $rowData) {
|
||||
if (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)) {
|
||||
break;
|
||||
}
|
||||
$rowNumber = $rowKey;
|
||||
$rowValue = $rowData[$firstColumn];
|
||||
}
|
||||
|
||||
if ($rowNumber !== false) {
|
||||
if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
|
||||
// if an exact match is required, we have what we need to return an appropriate response
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
} else {
|
||||
// otherwise return the appropriate value
|
||||
return $lookup_array[$rowNumber][$returnColumn];
|
||||
}
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
} // function VLOOKUP()
|
||||
|
||||
|
||||
/**
|
||||
* LOOKUP
|
||||
* The LOOKUP function searches for value either from a one-row or one-column range or from an array.
|
||||
* @param lookup_value The value that you want to match in lookup_array
|
||||
* @param lookup_vector The range of cells being searched
|
||||
* @param result_vector The column from which the matching value must be returned
|
||||
* @return mixed The value of the found cell
|
||||
*/
|
||||
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector=null) {
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
|
||||
if (!is_array($lookup_vector)) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
$lookupRows = count($lookup_vector);
|
||||
$l = array_keys($lookup_vector);
|
||||
$l = array_shift($l);
|
||||
$lookupColumns = count($lookup_vector[$l]);
|
||||
if ((($lookupRows == 1) && ($lookupColumns > 1)) || (($lookupRows == 2) && ($lookupColumns != 2))) {
|
||||
$lookup_vector = self::TRANSPOSE($lookup_vector);
|
||||
$lookupRows = count($lookup_vector);
|
||||
$l = array_keys($lookup_vector);
|
||||
$lookupColumns = count($lookup_vector[array_shift($l)]);
|
||||
}
|
||||
|
||||
if (is_null($result_vector)) {
|
||||
$result_vector = $lookup_vector;
|
||||
}
|
||||
$resultRows = count($result_vector);
|
||||
$l = array_keys($result_vector);
|
||||
$l = array_shift($l);
|
||||
$resultColumns = count($result_vector[$l]);
|
||||
if ((($resultRows == 1) && ($resultColumns > 1)) || (($resultRows == 2) && ($resultColumns != 2))) {
|
||||
$result_vector = self::TRANSPOSE($result_vector);
|
||||
$resultRows = count($result_vector);
|
||||
$r = array_keys($result_vector);
|
||||
$resultColumns = count($result_vector[array_shift($r)]);
|
||||
}
|
||||
|
||||
if ($lookupRows == 2) {
|
||||
$result_vector = array_pop($lookup_vector);
|
||||
$lookup_vector = array_shift($lookup_vector);
|
||||
}
|
||||
if ($lookupColumns != 2) {
|
||||
foreach($lookup_vector as &$value) {
|
||||
if (is_array($value)) {
|
||||
$k = array_keys($value);
|
||||
$key1 = $key2 = array_shift($k);
|
||||
$key2++;
|
||||
$dataValue1 = $value[$key1];
|
||||
} else {
|
||||
$key1 = 0;
|
||||
$key2 = 1;
|
||||
$dataValue1 = $value;
|
||||
}
|
||||
$dataValue2 = array_shift($result_vector);
|
||||
if (is_array($dataValue2)) {
|
||||
$dataValue2 = array_shift($dataValue2);
|
||||
}
|
||||
$value = array($key1 => $dataValue1, $key2 => $dataValue2);
|
||||
}
|
||||
unset($value);
|
||||
}
|
||||
|
||||
return self::VLOOKUP($lookup_value,$lookup_vector,2);
|
||||
} // function LOOKUP()
|
||||
|
||||
} // class PHPExcel_Calculation_LookupRef
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,586 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_TextData
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_TextData {
|
||||
|
||||
private static $_invalidChars = Null;
|
||||
|
||||
private static function _uniord($c) {
|
||||
if (ord($c{0}) >=0 && ord($c{0}) <= 127)
|
||||
return ord($c{0});
|
||||
if (ord($c{0}) >= 192 && ord($c{0}) <= 223)
|
||||
return (ord($c{0})-192)*64 + (ord($c{1})-128);
|
||||
if (ord($c{0}) >= 224 && ord($c{0}) <= 239)
|
||||
return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
|
||||
if (ord($c{0}) >= 240 && ord($c{0}) <= 247)
|
||||
return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
|
||||
if (ord($c{0}) >= 248 && ord($c{0}) <= 251)
|
||||
return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
|
||||
if (ord($c{0}) >= 252 && ord($c{0}) <= 253)
|
||||
return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
|
||||
if (ord($c{0}) >= 254 && ord($c{0}) <= 255) //error
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return 0;
|
||||
} // function _uniord()
|
||||
|
||||
/**
|
||||
* CHARACTER
|
||||
*
|
||||
* @param string $character Value
|
||||
* @return int
|
||||
*/
|
||||
public static function CHARACTER($character) {
|
||||
$character = PHPExcel_Calculation_Functions::flattenSingleValue($character);
|
||||
|
||||
if ((!is_numeric($character)) || ($character < 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding('&#'.intval($character).';', 'UTF-8', 'HTML-ENTITIES');
|
||||
} else {
|
||||
return chr(intval($character));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TRIMNONPRINTABLE
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return string
|
||||
*/
|
||||
public static function TRIMNONPRINTABLE($stringValue = '') {
|
||||
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
|
||||
|
||||
if (is_bool($stringValue)) {
|
||||
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if (self::$_invalidChars == Null) {
|
||||
self::$_invalidChars = range(chr(0),chr(31));
|
||||
}
|
||||
|
||||
if (is_string($stringValue) || is_numeric($stringValue)) {
|
||||
return str_replace(self::$_invalidChars,'',trim($stringValue,"\x00..\x1F"));
|
||||
}
|
||||
return NULL;
|
||||
} // function TRIMNONPRINTABLE()
|
||||
|
||||
|
||||
/**
|
||||
* TRIMSPACES
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return string
|
||||
*/
|
||||
public static function TRIMSPACES($stringValue = '') {
|
||||
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
|
||||
|
||||
if (is_bool($stringValue)) {
|
||||
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if (is_string($stringValue) || is_numeric($stringValue)) {
|
||||
return trim(preg_replace('/ +/',' ',trim($stringValue,' ')));
|
||||
}
|
||||
return NULL;
|
||||
} // function TRIMSPACES()
|
||||
|
||||
|
||||
/**
|
||||
* ASCIICODE
|
||||
*
|
||||
* @param string $character Value
|
||||
* @return int
|
||||
*/
|
||||
public static function ASCIICODE($characters) {
|
||||
if (($characters === NULL) || ($characters === ''))
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
$characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters);
|
||||
if (is_bool($characters)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$characters = (int) $characters;
|
||||
} else {
|
||||
$characters = ($characters) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
}
|
||||
|
||||
$character = $characters;
|
||||
if ((function_exists('mb_strlen')) && (function_exists('mb_substr'))) {
|
||||
if (mb_strlen($characters, 'UTF-8') > 1) { $character = mb_substr($characters, 0, 1, 'UTF-8'); }
|
||||
return self::_uniord($character);
|
||||
} else {
|
||||
if (strlen($characters) > 0) { $character = substr($characters, 0, 1); }
|
||||
return ord($character);
|
||||
}
|
||||
} // function ASCIICODE()
|
||||
|
||||
|
||||
/**
|
||||
* CONCATENATE
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function CONCATENATE() {
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop through arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
foreach ($aArgs as $arg) {
|
||||
if (is_bool($arg)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$arg = (int) $arg;
|
||||
} else {
|
||||
$arg = ($arg) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
}
|
||||
$returnValue .= $arg;
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
} // function CONCATENATE()
|
||||
|
||||
|
||||
/**
|
||||
* DOLLAR
|
||||
*
|
||||
* This function converts a number to text using currency format, with the decimals rounded to the specified place.
|
||||
* The format used is $#,##0.00_);($#,##0.00)..
|
||||
*
|
||||
* @param float $value The value to format
|
||||
* @param int $decimals The number of digits to display to the right of the decimal point.
|
||||
* If decimals is negative, number is rounded to the left of the decimal point.
|
||||
* If you omit decimals, it is assumed to be 2
|
||||
* @return string
|
||||
*/
|
||||
public static function DOLLAR($value = 0, $decimals = 2) {
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
|
||||
|
||||
// Validate parameters
|
||||
if (!is_numeric($value) || !is_numeric($decimals)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
$decimals = floor($decimals);
|
||||
|
||||
if ($decimals > 0) {
|
||||
return money_format('%.'.$decimals.'n',$value);
|
||||
} else {
|
||||
$round = pow(10,abs($decimals));
|
||||
if ($value < 0) { $round = 0-$round; }
|
||||
$value = PHPExcel_Calculation_MathTrig::MROUND($value,$round);
|
||||
// The implementation of money_format used if the standard PHP function is not available can't handle decimal places of 0,
|
||||
// so we display to 1 dp and chop off that character and the decimal separator using substr
|
||||
return substr(money_format('%.1n',$value),0,-2);
|
||||
}
|
||||
} // function DOLLAR()
|
||||
|
||||
|
||||
/**
|
||||
* SEARCHSENSITIVE
|
||||
*
|
||||
* @param string $needle The string to look for
|
||||
* @param string $haystack The string in which to look
|
||||
* @param int $offset Offset within $haystack
|
||||
* @return string
|
||||
*/
|
||||
public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) {
|
||||
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
|
||||
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
|
||||
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
|
||||
|
||||
if (!is_bool($needle)) {
|
||||
if (is_bool($haystack)) {
|
||||
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) {
|
||||
if (PHPExcel_Shared_String::CountCharacters($needle) == 0) {
|
||||
return $offset;
|
||||
}
|
||||
if (function_exists('mb_strpos')) {
|
||||
$pos = mb_strpos($haystack, $needle, --$offset, 'UTF-8');
|
||||
} else {
|
||||
$pos = strpos($haystack, $needle, --$offset);
|
||||
}
|
||||
if ($pos !== false) {
|
||||
return ++$pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} // function SEARCHSENSITIVE()
|
||||
|
||||
|
||||
/**
|
||||
* SEARCHINSENSITIVE
|
||||
*
|
||||
* @param string $needle The string to look for
|
||||
* @param string $haystack The string in which to look
|
||||
* @param int $offset Offset within $haystack
|
||||
* @return string
|
||||
*/
|
||||
public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) {
|
||||
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
|
||||
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
|
||||
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
|
||||
|
||||
if (!is_bool($needle)) {
|
||||
if (is_bool($haystack)) {
|
||||
$haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) {
|
||||
if (PHPExcel_Shared_String::CountCharacters($needle) == 0) {
|
||||
return $offset;
|
||||
}
|
||||
if (function_exists('mb_stripos')) {
|
||||
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
|
||||
} else {
|
||||
$pos = stripos($haystack, $needle, --$offset);
|
||||
}
|
||||
if ($pos !== false) {
|
||||
return ++$pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} // function SEARCHINSENSITIVE()
|
||||
|
||||
|
||||
/**
|
||||
* FIXEDFORMAT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) {
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
|
||||
$no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);
|
||||
|
||||
// Validate parameters
|
||||
if (!is_numeric($value) || !is_numeric($decimals)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
$decimals = floor($decimals);
|
||||
|
||||
$valueResult = round($value,$decimals);
|
||||
if ($decimals < 0) { $decimals = 0; }
|
||||
if (!$no_commas) {
|
||||
$valueResult = number_format($valueResult,$decimals);
|
||||
}
|
||||
|
||||
return (string) $valueResult;
|
||||
} // function FIXEDFORMAT()
|
||||
|
||||
|
||||
/**
|
||||
* LEFT
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $chars Number of characters
|
||||
* @return string
|
||||
*/
|
||||
public static function LEFT($value = '', $chars = 1) {
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
|
||||
if ($chars < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if (function_exists('mb_substr')) {
|
||||
return mb_substr($value, 0, $chars, 'UTF-8');
|
||||
} else {
|
||||
return substr($value, 0, $chars);
|
||||
}
|
||||
} // function LEFT()
|
||||
|
||||
|
||||
/**
|
||||
* MID
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $start Start character
|
||||
* @param int $chars Number of characters
|
||||
* @return string
|
||||
*/
|
||||
public static function MID($value = '', $start = 1, $chars = null) {
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
|
||||
if (($start < 1) || ($chars < 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if (function_exists('mb_substr')) {
|
||||
return mb_substr($value, --$start, $chars, 'UTF-8');
|
||||
} else {
|
||||
return substr($value, --$start, $chars);
|
||||
}
|
||||
} // function MID()
|
||||
|
||||
|
||||
/**
|
||||
* RIGHT
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $chars Number of characters
|
||||
* @return string
|
||||
*/
|
||||
public static function RIGHT($value = '', $chars = 1) {
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
|
||||
if ($chars < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) {
|
||||
return mb_substr($value, mb_strlen($value, 'UTF-8') - $chars, $chars, 'UTF-8');
|
||||
} else {
|
||||
return substr($value, strlen($value) - $chars);
|
||||
}
|
||||
} // function RIGHT()
|
||||
|
||||
|
||||
/**
|
||||
* STRINGLENGTH
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $chars Number of characters
|
||||
* @return string
|
||||
*/
|
||||
public static function STRINGLENGTH($value = '') {
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
|
||||
if (is_bool($value)) {
|
||||
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
if (function_exists('mb_strlen')) {
|
||||
return mb_strlen($value, 'UTF-8');
|
||||
} else {
|
||||
return strlen($value);
|
||||
}
|
||||
} // function STRINGLENGTH()
|
||||
|
||||
|
||||
/**
|
||||
* LOWERCASE
|
||||
*
|
||||
* Converts a string value to upper case.
|
||||
*
|
||||
* @param string $mixedCaseString
|
||||
* @return string
|
||||
*/
|
||||
public static function LOWERCASE($mixedCaseString) {
|
||||
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
|
||||
|
||||
if (is_bool($mixedCaseString)) {
|
||||
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
return PHPExcel_Shared_String::StrToLower($mixedCaseString);
|
||||
} // function LOWERCASE()
|
||||
|
||||
|
||||
/**
|
||||
* UPPERCASE
|
||||
*
|
||||
* Converts a string value to upper case.
|
||||
*
|
||||
* @param string $mixedCaseString
|
||||
* @return string
|
||||
*/
|
||||
public static function UPPERCASE($mixedCaseString) {
|
||||
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
|
||||
|
||||
if (is_bool($mixedCaseString)) {
|
||||
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
return PHPExcel_Shared_String::StrToUpper($mixedCaseString);
|
||||
} // function UPPERCASE()
|
||||
|
||||
|
||||
/**
|
||||
* PROPERCASE
|
||||
*
|
||||
* Converts a string value to upper case.
|
||||
*
|
||||
* @param string $mixedCaseString
|
||||
* @return string
|
||||
*/
|
||||
public static function PROPERCASE($mixedCaseString) {
|
||||
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
|
||||
|
||||
if (is_bool($mixedCaseString)) {
|
||||
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
||||
return PHPExcel_Shared_String::StrToTitle($mixedCaseString);
|
||||
} // function PROPERCASE()
|
||||
|
||||
|
||||
/**
|
||||
* REPLACE
|
||||
*
|
||||
* @param string $value Value
|
||||
* @param int $start Start character
|
||||
* @param int $chars Number of characters
|
||||
* @return string
|
||||
*/
|
||||
public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText) {
|
||||
$oldText = PHPExcel_Calculation_Functions::flattenSingleValue($oldText);
|
||||
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
$newText = PHPExcel_Calculation_Functions::flattenSingleValue($newText);
|
||||
|
||||
$left = self::LEFT($oldText,$start-1);
|
||||
$right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-($start+$chars)+1);
|
||||
|
||||
return $left.$newText.$right;
|
||||
} // function REPLACE()
|
||||
|
||||
|
||||
/**
|
||||
* SUBSTITUTE
|
||||
*
|
||||
* @param string $text Value
|
||||
* @param string $fromText From Value
|
||||
* @param string $toText To Value
|
||||
* @param integer $instance Instance Number
|
||||
* @return string
|
||||
*/
|
||||
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) {
|
||||
$text = PHPExcel_Calculation_Functions::flattenSingleValue($text);
|
||||
$fromText = PHPExcel_Calculation_Functions::flattenSingleValue($fromText);
|
||||
$toText = PHPExcel_Calculation_Functions::flattenSingleValue($toText);
|
||||
$instance = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance));
|
||||
|
||||
if ($instance == 0) {
|
||||
if(function_exists('mb_str_replace')) {
|
||||
return mb_str_replace($fromText,$toText,$text);
|
||||
} else {
|
||||
return str_replace($fromText,$toText,$text);
|
||||
}
|
||||
} else {
|
||||
$pos = -1;
|
||||
while($instance > 0) {
|
||||
if (function_exists('mb_strpos')) {
|
||||
$pos = mb_strpos($text, $fromText, $pos+1, 'UTF-8');
|
||||
} else {
|
||||
$pos = strpos($text, $fromText, $pos+1);
|
||||
}
|
||||
if ($pos === false) {
|
||||
break;
|
||||
}
|
||||
--$instance;
|
||||
}
|
||||
if ($pos !== false) {
|
||||
if (function_exists('mb_strlen')) {
|
||||
return self::REPLACE($text,++$pos,mb_strlen($fromText, 'UTF-8'),$toText);
|
||||
} else {
|
||||
return self::REPLACE($text,++$pos,strlen($fromText),$toText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
} // function SUBSTITUTE()
|
||||
|
||||
|
||||
/**
|
||||
* RETURNSTRING
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function RETURNSTRING($testValue = '') {
|
||||
$testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
|
||||
|
||||
if (is_string($testValue)) {
|
||||
return $testValue;
|
||||
}
|
||||
return Null;
|
||||
} // function RETURNSTRING()
|
||||
|
||||
|
||||
/**
|
||||
* TEXTFORMAT
|
||||
*
|
||||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function TEXTFORMAT($value,$format) {
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$format = PHPExcel_Calculation_Functions::flattenSingleValue($format);
|
||||
|
||||
if ((is_string($value)) && (!is_numeric($value)) && PHPExcel_Shared_Date::isDateTimeFormatCode($format)) {
|
||||
$value = PHPExcel_Calculation_DateTime::DATEVALUE($value);
|
||||
}
|
||||
|
||||
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format);
|
||||
} // function TEXTFORMAT()
|
||||
|
||||
} // class PHPExcel_Calculation_TextData
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
class PHPExcel_Calculation_Token_Stack {
|
||||
|
||||
private $_stack = array();
|
||||
private $_count = 0;
|
||||
|
||||
|
||||
public function count() {
|
||||
return $this->_count;
|
||||
} // function count()
|
||||
|
||||
|
||||
public function push($type,$value,$reference=null) {
|
||||
$this->_stack[$this->_count++] = array('type' => $type,
|
||||
'value' => $value,
|
||||
'reference' => $reference
|
||||
);
|
||||
if ($type == 'Function') {
|
||||
$localeFunction = PHPExcel_Calculation::_localeFunc($value);
|
||||
if ($localeFunction != $value) {
|
||||
$this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
|
||||
}
|
||||
}
|
||||
} // function push()
|
||||
|
||||
|
||||
public function pop() {
|
||||
if ($this->_count > 0) {
|
||||
return $this->_stack[--$this->_count];
|
||||
}
|
||||
return null;
|
||||
} // function pop()
|
||||
|
||||
|
||||
public function last($n=1) {
|
||||
if ($this->_count-$n < 0) {
|
||||
return null;
|
||||
}
|
||||
return $this->_stack[$this->_count-$n];
|
||||
} // function last()
|
||||
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
} // class PHPExcel_Calculation_Token_Stack
|
|
@ -0,0 +1,351 @@
|
|||
ABS
|
||||
ACCRINT
|
||||
ACCRINTM
|
||||
ACOS
|
||||
ACOSH
|
||||
ADDRESS
|
||||
AMORDEGRC
|
||||
AMORLINC
|
||||
AND
|
||||
AREAS
|
||||
ASC
|
||||
ASIN
|
||||
ASINH
|
||||
ATAN
|
||||
ATAN2
|
||||
ATANH
|
||||
AVEDEV
|
||||
AVERAGE
|
||||
AVERAGEA
|
||||
AVERAGEIF
|
||||
AVERAGEIFS
|
||||
BAHTTEXT
|
||||
BESSELI
|
||||
BESSELJ
|
||||
BESSELK
|
||||
BESSELY
|
||||
BETADIST
|
||||
BETAINV
|
||||
BIN2DEC
|
||||
BIN2HEX
|
||||
BIN2OCT
|
||||
BINOMDIST
|
||||
CEILING
|
||||
CELL
|
||||
CHAR
|
||||
CHIDIST
|
||||
CHIINV
|
||||
CHITEST
|
||||
CHOOSE
|
||||
CLEAN
|
||||
CODE
|
||||
COLUMN
|
||||
COLUMNS
|
||||
COMBIN
|
||||
COMPLEX
|
||||
CONCATENATE
|
||||
CONFIDENCE
|
||||
CONVERT
|
||||
CORREL
|
||||
COS
|
||||
COSH
|
||||
COUNT
|
||||
COUNTA
|
||||
COUNTBLANK
|
||||
COUNTIF
|
||||
COUNTIFS
|
||||
COUPDAYBS
|
||||
COUPDAYBS
|
||||
COUPDAYSNC
|
||||
COUPNCD
|
||||
COUPNUM
|
||||
COUPPCD
|
||||
COVAR
|
||||
CRITBINOM
|
||||
CUBEKPIMEMBER
|
||||
CUBEMEMBER
|
||||
CUBEMEMBERPROPERTY
|
||||
CUBERANKEDMEMBER
|
||||
CUBESET
|
||||
CUBESETCOUNT
|
||||
CUBEVALUE
|
||||
CUMIPMT
|
||||
CUMPRINC
|
||||
DATE
|
||||
DATEDIF
|
||||
DATEVALUE
|
||||
DAVERAGE
|
||||
DAY
|
||||
DAYS360
|
||||
DB
|
||||
DCOUNT
|
||||
DCOUNTA
|
||||
DDB
|
||||
DEC2BIN
|
||||
DEC2HEX
|
||||
DEC2OCT
|
||||
DEGREES
|
||||
DELTA
|
||||
DEVSQ
|
||||
DGET
|
||||
DISC
|
||||
DMAX
|
||||
DMIN
|
||||
DOLLAR
|
||||
DOLLARDE
|
||||
DOLLARFR
|
||||
DPRODUCT
|
||||
DSTDEV
|
||||
DSTDEVP
|
||||
DSUM
|
||||
DURATION
|
||||
DVAR
|
||||
DVARP
|
||||
EDATE
|
||||
EFFECT
|
||||
EOMONTH
|
||||
ERF
|
||||
ERFC
|
||||
ERROR.TYPE
|
||||
EVEN
|
||||
EXACT
|
||||
EXP
|
||||
EXPONDIST
|
||||
FACT
|
||||
FACTDOUBLE
|
||||
FALSE
|
||||
FDIST
|
||||
FIND
|
||||
FINDB
|
||||
FINV
|
||||
FISHER
|
||||
FISHERINV
|
||||
FIXED
|
||||
FLOOR
|
||||
FORECAST
|
||||
FREQUENCY
|
||||
FTEST
|
||||
FV
|
||||
FVSCHEDULE
|
||||
GAMAMDIST
|
||||
GAMMAINV
|
||||
GAMMALN
|
||||
GCD
|
||||
GEOMEAN
|
||||
GESTEP
|
||||
GETPIVOTDATA
|
||||
GROWTH
|
||||
HARMEAN
|
||||
HEX2BIN
|
||||
HEX2OCT
|
||||
HLOOKUP
|
||||
HOUR
|
||||
HYPERLINK
|
||||
HYPGEOMDIST
|
||||
IF
|
||||
IFERROR
|
||||
IMABS
|
||||
IMAGINARY
|
||||
IMARGUMENT
|
||||
IMCONJUGATE
|
||||
IMCOS
|
||||
IMEXP
|
||||
IMLN
|
||||
IMLOG10
|
||||
IMLOG2
|
||||
IMPOWER
|
||||
IMPRODUCT
|
||||
IMREAL
|
||||
IMSIN
|
||||
IMSQRT
|
||||
IMSUB
|
||||
IMSUM
|
||||
INDEX
|
||||
INDIRECT
|
||||
INFO
|
||||
INT
|
||||
INTERCEPT
|
||||
INTRATE
|
||||
IPMT
|
||||
IRR
|
||||
ISBLANK
|
||||
ISERR
|
||||
ISERROR
|
||||
ISEVEN
|
||||
ISLOGICAL
|
||||
ISNA
|
||||
ISNONTEXT
|
||||
ISNUMBER
|
||||
ISODD
|
||||
ISPMT
|
||||
ISREF
|
||||
ISTEXT
|
||||
JIS
|
||||
KURT
|
||||
LARGE
|
||||
LCM
|
||||
LEFT
|
||||
LEFTB
|
||||
LEN
|
||||
LENB
|
||||
LINEST
|
||||
LN
|
||||
LOG
|
||||
LOG10
|
||||
LOGEST
|
||||
LOGINV
|
||||
LOGNORMDIST
|
||||
LOOKUP
|
||||
LOWER
|
||||
MATCH
|
||||
MAX
|
||||
MAXA
|
||||
MDETERM
|
||||
MDURATION
|
||||
MEDIAN
|
||||
MID
|
||||
MIDB
|
||||
MIN
|
||||
MINA
|
||||
MINUTE
|
||||
MINVERSE
|
||||
MIRR
|
||||
MMULT
|
||||
MOD
|
||||
MODE
|
||||
MONTH
|
||||
MROUND
|
||||
MULTINOMIAL
|
||||
N
|
||||
NA
|
||||
NEGBINOMDIST
|
||||
NETWORKDAYS
|
||||
NOMINAL
|
||||
NORMDIST
|
||||
NORMINV
|
||||
NORMSDIST
|
||||
NORMSINV
|
||||
NOT
|
||||
NOW
|
||||
NPER
|
||||
NPV
|
||||
OCT2BIN
|
||||
OCT2DEC
|
||||
OCT2HEX
|
||||
ODD
|
||||
ODDFPRICE
|
||||
ODDFYIELD
|
||||
ODDLPRICE
|
||||
ODDLYIELD
|
||||
OFFSET
|
||||
OR
|
||||
PEARSON
|
||||
PERCENTILE
|
||||
PERCENTRANK
|
||||
PERMUT
|
||||
PHONETIC
|
||||
PI
|
||||
PMT
|
||||
POISSON
|
||||
POWER
|
||||
PPMT
|
||||
PRICE
|
||||
PRICEDISC
|
||||
PRICEMAT
|
||||
PROB
|
||||
PRODUCT
|
||||
PROPER
|
||||
PV
|
||||
QUARTILE
|
||||
QUOTIENT
|
||||
RADIANS
|
||||
RAND
|
||||
RANDBETWEEN
|
||||
RANK
|
||||
RATE
|
||||
RECEIVED
|
||||
REPLACE
|
||||
REPLACEB
|
||||
REPT
|
||||
RIGHT
|
||||
RIGHTB
|
||||
ROMAN
|
||||
ROUND
|
||||
ROUNDDOWN
|
||||
ROUNDUP
|
||||
ROW
|
||||
ROWS
|
||||
RSQ
|
||||
RTD
|
||||
SEARCH
|
||||
SEARCHB
|
||||
SECOND
|
||||
SERIESSUM
|
||||
SIGN
|
||||
SIN
|
||||
SINH
|
||||
SKEW
|
||||
SLN
|
||||
SLOPE
|
||||
SMALL
|
||||
SQRT
|
||||
SQRTPI
|
||||
STANDARDIZE
|
||||
STDEV
|
||||
STDEVA
|
||||
STDEVP
|
||||
STDEVPA
|
||||
STEYX
|
||||
SUBSTITUTE
|
||||
SUBTOTAL
|
||||
SUM
|
||||
SUMIF
|
||||
SUMIFS
|
||||
SUMPRODUCT
|
||||
SUMSQ
|
||||
SUMX2MY2
|
||||
SUMX2PY2
|
||||
SUMXMY2
|
||||
SYD
|
||||
T
|
||||
TAN
|
||||
TANH
|
||||
TBILLEQ
|
||||
TBILLPRICE
|
||||
TBILLYIELD
|
||||
TDIST
|
||||
TEXT
|
||||
TIME
|
||||
TIMEVALUE
|
||||
TINV
|
||||
TODAY
|
||||
TRANSPOSE
|
||||
TREND
|
||||
TRIM
|
||||
TRIMMEAN
|
||||
TRUE
|
||||
TRUNC
|
||||
TTEST
|
||||
TYPE
|
||||
UPPER
|
||||
USDOLLAR
|
||||
VALUE
|
||||
VAR
|
||||
VARA
|
||||
VARP
|
||||
VARPA
|
||||
VDB
|
||||
VERSION
|
||||
VLOOKUP
|
||||
WEEKDAY
|
||||
WEEKNUM
|
||||
WEIBULL
|
||||
WORKDAY
|
||||
XIRR
|
||||
XNPV
|
||||
YEAR
|
||||
YEARFRAC
|
||||
YIELD
|
||||
YIELDDISC
|
||||
YIELDMAT
|
||||
ZTEST
|
|
@ -0,0 +1,972 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell
|
||||
{
|
||||
|
||||
/**
|
||||
* Default range variable constant
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DEFAULT_RANGE = 'A1:A1';
|
||||
|
||||
/**
|
||||
* Value binder to use
|
||||
*
|
||||
* @var PHPExcel_Cell_IValueBinder
|
||||
*/
|
||||
private static $_valueBinder = NULL;
|
||||
|
||||
/**
|
||||
* Column of the cell
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_column;
|
||||
|
||||
/**
|
||||
* Row of the cell
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_row;
|
||||
|
||||
/**
|
||||
* Value of the cell
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_value;
|
||||
|
||||
/**
|
||||
* Calculated value of the cell (used for caching)
|
||||
* This returns the value last calculated by MS Excel or whichever spreadsheet program was used to
|
||||
* create the original spreadsheet file.
|
||||
* Note that this value is not guaranteed to reflect the actual calculated value because it is
|
||||
* possible that auto-calculation was disabled in the original spreadsheet, and underlying data
|
||||
* values used by the formula have changed since it was last calculated.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_calculatedValue = NULL;
|
||||
|
||||
/**
|
||||
* Type of the cell data
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dataType;
|
||||
|
||||
/**
|
||||
* Parent worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Index to cellXf
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_xfIndex;
|
||||
|
||||
/**
|
||||
* Attributes of the formula
|
||||
*
|
||||
*/
|
||||
private $_formulaAttributes;
|
||||
|
||||
|
||||
/**
|
||||
* Send notification to the cache controller
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function notifyCacheController() {
|
||||
$this->_parent->getCellCacheController()->updateCacheData($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function detach() {
|
||||
$this->_parent = NULL;
|
||||
}
|
||||
|
||||
public function attach($parent) {
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Cell
|
||||
*
|
||||
* @param string $pColumn
|
||||
* @param int $pRow
|
||||
* @param mixed $pValue
|
||||
* @param string $pDataType
|
||||
* @param PHPExcel_Worksheet $pSheet
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct($pColumn = 'A', $pRow = 1, $pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL)
|
||||
{
|
||||
// Initialise cell coordinate
|
||||
$this->_column = strtoupper($pColumn);
|
||||
$this->_row = $pRow;
|
||||
|
||||
// Initialise cell value
|
||||
$this->_value = $pValue;
|
||||
|
||||
// Set worksheet
|
||||
$this->_parent = $pSheet;
|
||||
|
||||
// Set datatype?
|
||||
if ($pDataType !== NULL) {
|
||||
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
|
||||
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
$this->_dataType = $pDataType;
|
||||
} else {
|
||||
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
||||
throw new PHPExcel_Exception("Value could not be bound to cell.");
|
||||
}
|
||||
}
|
||||
|
||||
// set default index to cellXf
|
||||
$this->_xfIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell coordinate column
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return $this->_column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell coordinate row
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRow()
|
||||
{
|
||||
return $this->_row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell coordinate
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCoordinate()
|
||||
{
|
||||
return $this->_column . $this->_row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell value with formatting
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormattedValue()
|
||||
{
|
||||
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
|
||||
$this->getCalculatedValue(),
|
||||
$this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())
|
||||
->getNumberFormat()->getFormatCode()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell value
|
||||
*
|
||||
* Sets the value for a cell, automatically determining the datatype using the value binder
|
||||
*
|
||||
* @param mixed $pValue Value
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function setValue($pValue = NULL)
|
||||
{
|
||||
if (!self::getValueBinder()->bindValue($this, $pValue)) {
|
||||
throw new PHPExcel_Exception("Value could not be bound to cell.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder)
|
||||
*
|
||||
* @param mixed $pValue Value
|
||||
* @param string $pDataType Explicit data type
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function setValueExplicit($pValue = NULL, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
|
||||
{
|
||||
// set the value according to data type
|
||||
switch ($pDataType) {
|
||||
case PHPExcel_Cell_DataType::TYPE_STRING2:
|
||||
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
case PHPExcel_Cell_DataType::TYPE_STRING:
|
||||
case PHPExcel_Cell_DataType::TYPE_NULL:
|
||||
case PHPExcel_Cell_DataType::TYPE_INLINE:
|
||||
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
|
||||
break;
|
||||
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
|
||||
$this->_value = (float)$pValue;
|
||||
break;
|
||||
case PHPExcel_Cell_DataType::TYPE_FORMULA:
|
||||
$this->_value = (string)$pValue;
|
||||
break;
|
||||
case PHPExcel_Cell_DataType::TYPE_BOOL:
|
||||
$this->_value = (bool)$pValue;
|
||||
break;
|
||||
case PHPExcel_Cell_DataType::TYPE_ERROR:
|
||||
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
|
||||
break;
|
||||
default:
|
||||
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
|
||||
break;
|
||||
}
|
||||
|
||||
// set the datatype
|
||||
$this->_dataType = $pDataType;
|
||||
|
||||
return $this->notifyCacheController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get calculated cell value
|
||||
*
|
||||
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
|
||||
*
|
||||
* @return mixed
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function getCalculatedValue($resetLog = TRUE)
|
||||
{
|
||||
// echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'<br />';
|
||||
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
try {
|
||||
// echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value<br />';
|
||||
$result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog);
|
||||
// echo $this->getCoordinate().' calculation result is '.$result.'<br />';
|
||||
} catch ( Exception $ex ) {
|
||||
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
|
||||
// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />';
|
||||
return $this->_calculatedValue; // Fallback for calculations referencing external files.
|
||||
}
|
||||
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
|
||||
$result = '#N/A';
|
||||
throw(
|
||||
new PHPExcel_Exception(
|
||||
$this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($result === '#Not Yet Implemented') {
|
||||
// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />';
|
||||
return $this->_calculatedValue; // Fallback if calculation engine does not support the formula.
|
||||
}
|
||||
// echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().'<br />';
|
||||
return $result;
|
||||
}
|
||||
|
||||
// if ($this->_value === NULL) {
|
||||
// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise<br />';
|
||||
// return NULL;
|
||||
// }
|
||||
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
|
||||
return $this->_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set old calculated value (cached)
|
||||
*
|
||||
* @param mixed $pValue Value
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function setCalculatedValue($pValue = NULL)
|
||||
{
|
||||
if ($pValue !== NULL) {
|
||||
$this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
|
||||
}
|
||||
|
||||
return $this->notifyCacheController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get old calculated value (cached)
|
||||
* This returns the value last calculated by MS Excel or whichever spreadsheet program was used to
|
||||
* create the original spreadsheet file.
|
||||
* Note that this value is not guaranteed to refelect the actual calculated value because it is
|
||||
* possible that auto-calculation was disabled in the original spreadsheet, and underlying data
|
||||
* values used by the formula have changed since it was last calculated.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOldCalculatedValue()
|
||||
{
|
||||
return $this->_calculatedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell data type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataType()
|
||||
{
|
||||
return $this->_dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell data type
|
||||
*
|
||||
* @param string $pDataType
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
|
||||
{
|
||||
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
|
||||
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
$this->_dataType = $pDataType;
|
||||
|
||||
return $this->notifyCacheController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this cell contain Data validation rules?
|
||||
*
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function hasDataValidation()
|
||||
{
|
||||
if (!isset($this->_parent)) {
|
||||
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
|
||||
}
|
||||
|
||||
return $this->_parent->dataValidationExists($this->getCoordinate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Data validation rules
|
||||
*
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function getDataValidation()
|
||||
{
|
||||
if (!isset($this->_parent)) {
|
||||
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
|
||||
}
|
||||
|
||||
return $this->_parent->getDataValidation($this->getCoordinate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data validation rules
|
||||
*
|
||||
* @param PHPExcel_Cell_DataValidation $pDataValidation
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = NULL)
|
||||
{
|
||||
if (!isset($this->_parent)) {
|
||||
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
|
||||
}
|
||||
|
||||
$this->_parent->setDataValidation($this->getCoordinate(), $pDataValidation);
|
||||
|
||||
return $this->notifyCacheController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this cell contain a Hyperlink?
|
||||
*
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function hasHyperlink()
|
||||
{
|
||||
if (!isset($this->_parent)) {
|
||||
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
|
||||
}
|
||||
|
||||
return $this->_parent->hyperlinkExists($this->getCoordinate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Hyperlink
|
||||
*
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function getHyperlink()
|
||||
{
|
||||
if (!isset($this->_parent)) {
|
||||
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
|
||||
}
|
||||
|
||||
return $this->_parent->getHyperlink($this->getCoordinate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Hyperlink
|
||||
*
|
||||
* @param PHPExcel_Cell_Hyperlink $pHyperlink
|
||||
* @return PHPExcel_Cell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = NULL)
|
||||
{
|
||||
if (!isset($this->_parent)) {
|
||||
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
|
||||
}
|
||||
|
||||
$this->_parent->setHyperlink($this->getCoordinate(), $pHyperlink);
|
||||
|
||||
return $this->notifyCacheController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-bind parent
|
||||
*
|
||||
* @param PHPExcel_Worksheet $parent
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function rebindParent(PHPExcel_Worksheet $parent) {
|
||||
$this->_parent = $parent;
|
||||
|
||||
return $this->notifyCacheController();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is cell in a specific range?
|
||||
*
|
||||
* @param string $pRange Cell range (e.g. A1:A1)
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInRange($pRange = 'A1:A1')
|
||||
{
|
||||
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
|
||||
|
||||
// Translate properties
|
||||
$myColumn = self::columnIndexFromString($this->getColumn());
|
||||
$myRow = $this->getRow();
|
||||
|
||||
// Verify if cell is in range
|
||||
return (($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) &&
|
||||
($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Coordinate from string
|
||||
*
|
||||
* @param string $pCoordinateString
|
||||
* @return array Array containing column and row (indexes 0 and 1)
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public static function coordinateFromString($pCoordinateString = 'A1')
|
||||
{
|
||||
if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
|
||||
return array($matches[1],$matches[2]);
|
||||
} elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) {
|
||||
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
|
||||
} elseif ($pCoordinateString == '') {
|
||||
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string');
|
||||
}
|
||||
|
||||
throw new PHPExcel_Exception('Invalid cell coordinate '.$pCoordinateString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make string row, column or cell coordinate absolute
|
||||
*
|
||||
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
|
||||
* Note that this value can be a row or column reference as well as a cell reference
|
||||
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public static function absoluteReference($pCoordinateString = 'A1')
|
||||
{
|
||||
if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
|
||||
// Split out any worksheet name from the reference
|
||||
$worksheet = '';
|
||||
$cellAddress = explode('!',$pCoordinateString);
|
||||
if (count($cellAddress) > 1) {
|
||||
list($worksheet,$pCoordinateString) = $cellAddress;
|
||||
}
|
||||
if ($worksheet > '') $worksheet .= '!';
|
||||
|
||||
// Create absolute coordinate
|
||||
if (ctype_digit($pCoordinateString)) {
|
||||
return $worksheet . '$' . $pCoordinateString;
|
||||
} elseif (ctype_alpha($pCoordinateString)) {
|
||||
return $worksheet . '$' . strtoupper($pCoordinateString);
|
||||
}
|
||||
return $worksheet . self::absoluteCoordinate($pCoordinateString);
|
||||
}
|
||||
|
||||
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
|
||||
}
|
||||
|
||||
/**
|
||||
* Make string coordinate absolute
|
||||
*
|
||||
* @param string $pCoordinateString e.g. 'A1'
|
||||
* @return string Absolute coordinate e.g. '$A$1'
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public static function absoluteCoordinate($pCoordinateString = 'A1')
|
||||
{
|
||||
if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) {
|
||||
// Split out any worksheet name from the coordinate
|
||||
$worksheet = '';
|
||||
$cellAddress = explode('!',$pCoordinateString);
|
||||
if (count($cellAddress) > 1) {
|
||||
list($worksheet,$pCoordinateString) = $cellAddress;
|
||||
}
|
||||
if ($worksheet > '') $worksheet .= '!';
|
||||
|
||||
// Create absolute coordinate
|
||||
list($column, $row) = self::coordinateFromString($pCoordinateString);
|
||||
$column = ltrim($column,'$');
|
||||
$row = ltrim($row,'$');
|
||||
return $worksheet . '$' . $column . '$' . $row;
|
||||
}
|
||||
|
||||
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
|
||||
}
|
||||
|
||||
/**
|
||||
* Split range into coordinate strings
|
||||
*
|
||||
* @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4'
|
||||
* @return array Array containg one or more arrays containing one or two coordinate strings
|
||||
* e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11'))
|
||||
* or array('B4')
|
||||
*/
|
||||
public static function splitRange($pRange = 'A1:A1')
|
||||
{
|
||||
// Ensure $pRange is a valid range
|
||||
if(empty($pRange)) {
|
||||
$pRange = self::DEFAULT_RANGE;
|
||||
}
|
||||
|
||||
$exploded = explode(',', $pRange);
|
||||
$counter = count($exploded);
|
||||
for ($i = 0; $i < $counter; ++$i) {
|
||||
$exploded[$i] = explode(':', $exploded[$i]);
|
||||
}
|
||||
return $exploded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build range from coordinate strings
|
||||
*
|
||||
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings
|
||||
* @return string String representation of $pRange
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public static function buildRange($pRange)
|
||||
{
|
||||
// Verify range
|
||||
if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) {
|
||||
throw new PHPExcel_Exception('Range does not contain any information');
|
||||
}
|
||||
|
||||
// Build range
|
||||
$imploded = array();
|
||||
$counter = count($pRange);
|
||||
for ($i = 0; $i < $counter; ++$i) {
|
||||
$pRange[$i] = implode(':', $pRange[$i]);
|
||||
}
|
||||
$imploded = implode(',', $pRange);
|
||||
|
||||
return $imploded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate range boundaries
|
||||
*
|
||||
* @param string $pRange Cell range (e.g. A1:A1)
|
||||
* @return array Range coordinates array(Start Cell, End Cell)
|
||||
* where Start Cell and End Cell are arrays (Column Number, Row Number)
|
||||
*/
|
||||
public static function rangeBoundaries($pRange = 'A1:A1')
|
||||
{
|
||||
// Ensure $pRange is a valid range
|
||||
if(empty($pRange)) {
|
||||
$pRange = self::DEFAULT_RANGE;
|
||||
}
|
||||
|
||||
// Uppercase coordinate
|
||||
$pRange = strtoupper($pRange);
|
||||
|
||||
// Extract range
|
||||
if (strpos($pRange, ':') === FALSE) {
|
||||
$rangeA = $rangeB = $pRange;
|
||||
} else {
|
||||
list($rangeA, $rangeB) = explode(':', $pRange);
|
||||
}
|
||||
|
||||
// Calculate range outer borders
|
||||
$rangeStart = self::coordinateFromString($rangeA);
|
||||
$rangeEnd = self::coordinateFromString($rangeB);
|
||||
|
||||
// Translate column into index
|
||||
$rangeStart[0] = self::columnIndexFromString($rangeStart[0]);
|
||||
$rangeEnd[0] = self::columnIndexFromString($rangeEnd[0]);
|
||||
|
||||
return array($rangeStart, $rangeEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate range dimension
|
||||
*
|
||||
* @param string $pRange Cell range (e.g. A1:A1)
|
||||
* @return array Range dimension (width, height)
|
||||
*/
|
||||
public static function rangeDimension($pRange = 'A1:A1')
|
||||
{
|
||||
// Calculate range outer borders
|
||||
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
|
||||
|
||||
return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate range boundaries
|
||||
*
|
||||
* @param string $pRange Cell range (e.g. A1:A1)
|
||||
* @return array Range coordinates array(Start Cell, End Cell)
|
||||
* where Start Cell and End Cell are arrays (Column ID, Row Number)
|
||||
*/
|
||||
public static function getRangeBoundaries($pRange = 'A1:A1')
|
||||
{
|
||||
// Ensure $pRange is a valid range
|
||||
if(empty($pRange)) {
|
||||
$pRange = self::DEFAULT_RANGE;
|
||||
}
|
||||
|
||||
// Uppercase coordinate
|
||||
$pRange = strtoupper($pRange);
|
||||
|
||||
// Extract range
|
||||
if (strpos($pRange, ':') === FALSE) {
|
||||
$rangeA = $rangeB = $pRange;
|
||||
} else {
|
||||
list($rangeA, $rangeB) = explode(':', $pRange);
|
||||
}
|
||||
|
||||
return array( self::coordinateFromString($rangeA), self::coordinateFromString($rangeB));
|
||||
}
|
||||
|
||||
/**
|
||||
* Column index from string
|
||||
*
|
||||
* @param string $pString
|
||||
* @return int Column index (base 1 !!!)
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function columnIndexFromString($pString = 'A')
|
||||
{
|
||||
// Using a lookup cache adds a slight memory overhead, but boosts speed
|
||||
// caching using a static within the method is faster than a class static,
|
||||
// though it's additional memory overhead
|
||||
static $_indexCache = array();
|
||||
|
||||
if (isset($_indexCache[$pString]))
|
||||
return $_indexCache[$pString];
|
||||
|
||||
// It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord()
|
||||
// and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant
|
||||
// memory overhead either
|
||||
static $_columnLookup = array(
|
||||
'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13,
|
||||
'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26,
|
||||
'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13,
|
||||
'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26
|
||||
);
|
||||
|
||||
// We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString
|
||||
// for improved performance
|
||||
if (isset($pString{0})) {
|
||||
if (!isset($pString{1})) {
|
||||
$_indexCache[$pString] = $_columnLookup[$pString];
|
||||
return $_indexCache[$pString];
|
||||
} elseif(!isset($pString{2})) {
|
||||
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
|
||||
return $_indexCache[$pString];
|
||||
} elseif(!isset($pString{3})) {
|
||||
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
|
||||
return $_indexCache[$pString];
|
||||
}
|
||||
}
|
||||
throw new PHPExcel_Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty"));
|
||||
}
|
||||
|
||||
/**
|
||||
* String from columnindex
|
||||
*
|
||||
* @param int $pColumnIndex Column index (base 0 !!!)
|
||||
* @return string
|
||||
*/
|
||||
public static function stringFromColumnIndex($pColumnIndex = 0)
|
||||
{
|
||||
// Using a lookup cache adds a slight memory overhead, but boosts speed
|
||||
// caching using a static within the method is faster than a class static,
|
||||
// though it's additional memory overhead
|
||||
static $_indexCache = array();
|
||||
|
||||
if (!isset($_indexCache[$pColumnIndex])) {
|
||||
// Determine column string
|
||||
if ($pColumnIndex < 26) {
|
||||
$_indexCache[$pColumnIndex] = chr(65 + $pColumnIndex);
|
||||
} elseif ($pColumnIndex < 702) {
|
||||
$_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)) .
|
||||
chr(65 + $pColumnIndex % 26);
|
||||
} else {
|
||||
$_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676)) .
|
||||
chr(65 + ((($pColumnIndex - 26) % 676) / 26)) .
|
||||
chr(65 + $pColumnIndex % 26);
|
||||
}
|
||||
}
|
||||
return $_indexCache[$pColumnIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract all cell references in range
|
||||
*
|
||||
* @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
|
||||
* @return array Array containing single cell references
|
||||
*/
|
||||
public static function extractAllCellReferencesInRange($pRange = 'A1') {
|
||||
// Returnvalue
|
||||
$returnValue = array();
|
||||
|
||||
// Explode spaces
|
||||
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
|
||||
foreach ($cellBlocks as $cellBlock) {
|
||||
// Single cell?
|
||||
if (strpos($cellBlock,':') === FALSE && strpos($cellBlock,',') === FALSE) {
|
||||
$returnValue[] = $cellBlock;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Range...
|
||||
$ranges = self::splitRange($cellBlock);
|
||||
foreach($ranges as $range) {
|
||||
// Single cell?
|
||||
if (!isset($range[1])) {
|
||||
$returnValue[] = $range[0];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Range...
|
||||
list($rangeStart, $rangeEnd) = $range;
|
||||
list($startCol, $startRow) = sscanf($rangeStart,'%[A-Z]%d');
|
||||
list($endCol, $endRow) = sscanf($rangeEnd,'%[A-Z]%d');
|
||||
$endCol++;
|
||||
|
||||
// Current data
|
||||
$currentCol = $startCol;
|
||||
$currentRow = $startRow;
|
||||
|
||||
// Loop cells
|
||||
while ($currentCol != $endCol) {
|
||||
while ($currentRow <= $endRow) {
|
||||
$returnValue[] = $currentCol.$currentRow;
|
||||
++$currentRow;
|
||||
}
|
||||
++$currentCol;
|
||||
$currentRow = $startRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the result by column and row
|
||||
$sortKeys = array();
|
||||
foreach (array_unique($returnValue) as $coord) {
|
||||
list($column,$row) = sscanf($coord,'%[A-Z]%d');
|
||||
$sortKeys[sprintf('%3s%09d',$column,$row)] = $coord;
|
||||
}
|
||||
ksort($sortKeys);
|
||||
|
||||
// Return value
|
||||
return array_values($sortKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare 2 cells
|
||||
*
|
||||
* @param PHPExcel_Cell $a Cell a
|
||||
* @param PHPExcel_Cell $a Cell b
|
||||
* @return int Result of comparison (always -1 or 1, never zero!)
|
||||
*/
|
||||
public static function compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b)
|
||||
{
|
||||
if ($a->_row < $b->_row) {
|
||||
return -1;
|
||||
} elseif ($a->_row > $b->_row) {
|
||||
return 1;
|
||||
} elseif (self::columnIndexFromString($a->_column) < self::columnIndexFromString($b->_column)) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value binder to use
|
||||
*
|
||||
* @return PHPExcel_Cell_IValueBinder
|
||||
*/
|
||||
public static function getValueBinder() {
|
||||
if (self::$_valueBinder === NULL) {
|
||||
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder();
|
||||
}
|
||||
|
||||
return self::$_valueBinder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value binder to use
|
||||
*
|
||||
* @param PHPExcel_Cell_IValueBinder $binder
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) {
|
||||
if ($binder === NULL) {
|
||||
throw new Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
|
||||
}
|
||||
|
||||
self::$_valueBinder = $binder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if ((is_object($value)) && ($key != '_parent')) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index to cellXf
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getXfIndex()
|
||||
{
|
||||
return $this->_xfIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set index to cellXf
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function setXfIndex($pValue = 0)
|
||||
{
|
||||
$this->_xfIndex = $pValue;
|
||||
|
||||
return $this->notifyCacheController();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
|
||||
*/
|
||||
public function setFormulaAttributes($pAttributes)
|
||||
{
|
||||
$this->_formulaAttributes = $pAttributes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since version 1.7.8 for planned changes to cell for array formula handling
|
||||
*/
|
||||
public function getFormulaAttributes()
|
||||
{
|
||||
return $this->_formulaAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_AdvancedValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
|
||||
// Find out data type
|
||||
$dataType = parent::dataTypeForValue($value);
|
||||
|
||||
// Style logic - strings
|
||||
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
|
||||
// Test for booleans using locale-setting
|
||||
if ($value == PHPExcel_Calculation::getTRUE()) {
|
||||
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
} elseif($value == PHPExcel_Calculation::getFALSE()) {
|
||||
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for number in scientific format
|
||||
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for fraction
|
||||
if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] / $matches[3];
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '??/??' );
|
||||
return true;
|
||||
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] + ($matches[3] / $matches[4]);
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '# ??/??' );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for percentage
|
||||
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) str_replace('%', '', $value) / 100;
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for currency
|
||||
$currencyCode = PHPExcel_Shared_String::getCurrencyCode();
|
||||
$decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator();
|
||||
$thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator();
|
||||
if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode(
|
||||
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
|
||||
);
|
||||
return true;
|
||||
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array('$',','), '', $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for time without seconds e.g. '9:45', '09:45'
|
||||
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
|
||||
// Convert value to number
|
||||
list($h, $m) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440;
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for time with seconds '9:45:59', '09:45:59'
|
||||
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
|
||||
// Convert value to number
|
||||
list($h, $m, $s) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440 + $s / 86400;
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10'
|
||||
if (($d = PHPExcel_Shared_Date::stringToExcel($value)) !== false) {
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Determine style. Either there is a time part or not. Look for ':'
|
||||
if (strpos($value, ':') !== false) {
|
||||
$formatCode = 'yyyy-mm-dd h:mm';
|
||||
} else {
|
||||
$formatCode = 'yyyy-mm-dd';
|
||||
}
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode($formatCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for newline character "\n"
|
||||
if (strpos($value, "\n") !== FALSE) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getAlignment()->setWrapText(TRUE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Not bound yet? Use parent...
|
||||
return parent::bindValue($cell, $value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DataType
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DataType
|
||||
{
|
||||
/* Data types */
|
||||
const TYPE_STRING2 = 'str';
|
||||
const TYPE_STRING = 's';
|
||||
const TYPE_FORMULA = 'f';
|
||||
const TYPE_NUMERIC = 'n';
|
||||
const TYPE_BOOL = 'b';
|
||||
const TYPE_NULL = 'null';
|
||||
const TYPE_INLINE = 'inlineStr';
|
||||
const TYPE_ERROR = 'e';
|
||||
|
||||
/**
|
||||
* List of error codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_errorCodes = array('#NULL!' => 0, '#DIV/0!' => 1, '#VALUE!' => 2, '#REF!' => 3, '#NAME?' => 4, '#NUM!' => 5, '#N/A' => 6);
|
||||
|
||||
/**
|
||||
* Get list of error codes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getErrorCodes() {
|
||||
return self::$_errorCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure
|
||||
* @param mixed $pValue
|
||||
* @return int
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a string that it satisfies Excel requirements
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel string
|
||||
* @return mixed Sanitized value
|
||||
*/
|
||||
public static function checkString($pValue = null)
|
||||
{
|
||||
if ($pValue instanceof PHPExcel_RichText) {
|
||||
// TODO: Sanitize Rich-Text string (max. character count is 32,767)
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
// string must never be longer than 32,767 characters, truncate if necessary
|
||||
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
|
||||
|
||||
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
|
||||
$pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a value that it is a valid error code
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel error code
|
||||
* @return string Sanitized value
|
||||
*/
|
||||
public static function checkErrorCode($pValue = null)
|
||||
{
|
||||
$pValue = (string)$pValue;
|
||||
|
||||
if ( !array_key_exists($pValue, self::$_errorCodes) ) {
|
||||
$pValue = '#NULL!';
|
||||
}
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,474 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DataValidation
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DataValidation
|
||||
{
|
||||
/* Data validation types */
|
||||
const TYPE_NONE = 'none';
|
||||
const TYPE_CUSTOM = 'custom';
|
||||
const TYPE_DATE = 'date';
|
||||
const TYPE_DECIMAL = 'decimal';
|
||||
const TYPE_LIST = 'list';
|
||||
const TYPE_TEXTLENGTH = 'textLength';
|
||||
const TYPE_TIME = 'time';
|
||||
const TYPE_WHOLE = 'whole';
|
||||
|
||||
/* Data validation error styles */
|
||||
const STYLE_STOP = 'stop';
|
||||
const STYLE_WARNING = 'warning';
|
||||
const STYLE_INFORMATION = 'information';
|
||||
|
||||
/* Data validation operators */
|
||||
const OPERATOR_BETWEEN = 'between';
|
||||
const OPERATOR_EQUAL = 'equal';
|
||||
const OPERATOR_GREATERTHAN = 'greaterThan';
|
||||
const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
|
||||
const OPERATOR_LESSTHAN = 'lessThan';
|
||||
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
|
||||
const OPERATOR_NOTBETWEEN = 'notBetween';
|
||||
const OPERATOR_NOTEQUAL = 'notEqual';
|
||||
|
||||
/**
|
||||
* Formula 1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formula1;
|
||||
|
||||
/**
|
||||
* Formula 2
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formula2;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||
|
||||
/**
|
||||
* Error style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||
|
||||
/**
|
||||
* Operator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_operator;
|
||||
|
||||
/**
|
||||
* Allow Blank
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_allowBlank;
|
||||
|
||||
/**
|
||||
* Show DropDown
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showDropDown;
|
||||
|
||||
/**
|
||||
* Show InputMessage
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showInputMessage;
|
||||
|
||||
/**
|
||||
* Show ErrorMessage
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showErrorMessage;
|
||||
|
||||
/**
|
||||
* Error title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_errorTitle;
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_error;
|
||||
|
||||
/**
|
||||
* Prompt title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_promptTitle;
|
||||
|
||||
/**
|
||||
* Prompt
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_prompt;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Cell_DataValidation
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_formula1 = '';
|
||||
$this->_formula2 = '';
|
||||
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||
$this->_operator = '';
|
||||
$this->_allowBlank = false;
|
||||
$this->_showDropDown = false;
|
||||
$this->_showInputMessage = false;
|
||||
$this->_showErrorMessage = false;
|
||||
$this->_errorTitle = '';
|
||||
$this->_error = '';
|
||||
$this->_promptTitle = '';
|
||||
$this->_prompt = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Formula 1
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula1() {
|
||||
return $this->_formula1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Formula 1
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setFormula1($value = '') {
|
||||
$this->_formula1 = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Formula 2
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula2() {
|
||||
return $this->_formula2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Formula 2
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setFormula2($value = '') {
|
||||
$this->_formula2 = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType() {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Type
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
|
||||
$this->_type = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorStyle() {
|
||||
return $this->_errorStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Error style
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
|
||||
$this->_errorStyle = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Operator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOperator() {
|
||||
return $this->_operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Operator
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setOperator($value = '') {
|
||||
$this->_operator = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allow Blank
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getAllowBlank() {
|
||||
return $this->_allowBlank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Allow Blank
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setAllowBlank($value = false) {
|
||||
$this->_allowBlank = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show DropDown
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowDropDown() {
|
||||
return $this->_showDropDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Show DropDown
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setShowDropDown($value = false) {
|
||||
$this->_showDropDown = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show InputMessage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowInputMessage() {
|
||||
return $this->_showInputMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Show InputMessage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setShowInputMessage($value = false) {
|
||||
$this->_showInputMessage = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Show ErrorMessage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowErrorMessage() {
|
||||
return $this->_showErrorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Show ErrorMessage
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setShowErrorMessage($value = false) {
|
||||
$this->_showErrorMessage = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorTitle() {
|
||||
return $this->_errorTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Error title
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setErrorTitle($value = '') {
|
||||
$this->_errorTitle = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getError() {
|
||||
return $this->_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Error
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setError($value = '') {
|
||||
$this->_error = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Prompt title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPromptTitle() {
|
||||
return $this->_promptTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Prompt title
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setPromptTitle($value = '') {
|
||||
$this->_promptTitle = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Prompt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrompt() {
|
||||
return $this->_prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Prompt
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setPrompt($value = '') {
|
||||
$this->_prompt = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_formula1
|
||||
. $this->_formula2
|
||||
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
|
||||
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
|
||||
. $this->_operator
|
||||
. ($this->_allowBlank ? 't' : 'f')
|
||||
. ($this->_showDropDown ? 't' : 'f')
|
||||
. ($this->_showInputMessage ? 't' : 'f')
|
||||
. ($this->_showErrorMessage ? 't' : 'f')
|
||||
. $this->_errorTitle
|
||||
. $this->_error
|
||||
. $this->_promptTitle
|
||||
. $this->_prompt
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DefaultValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
|
||||
// Set value explicit
|
||||
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
|
||||
|
||||
// Done!
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @param mixed $pValue
|
||||
* @return int
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
// Match the value against a few data types
|
||||
if (is_null($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
|
||||
} elseif ($pValue === '') {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
} elseif ($pValue instanceof PHPExcel_RichText) {
|
||||
return PHPExcel_Cell_DataType::TYPE_INLINE;
|
||||
|
||||
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
|
||||
return PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
|
||||
} elseif (is_bool($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
|
||||
} elseif (is_float($pValue) || is_int($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
||||
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
||||
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
|
||||
return PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
|
||||
} else {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_Hyperlink
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_Hyperlink
|
||||
{
|
||||
/**
|
||||
* URL to link the cell to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_url;
|
||||
|
||||
/**
|
||||
* Tooltip to display on the hyperlink
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tooltip;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Cell_Hyperlink
|
||||
*
|
||||
* @param string $pUrl Url to link the cell to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pUrl = '', $pTooltip = '')
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_url = $pUrl;
|
||||
$this->_tooltip = $pTooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl() {
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set URL
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setUrl($value = '') {
|
||||
$this->_url = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tooltip
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTooltip() {
|
||||
return $this->_tooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tooltip
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setTooltip($value = '') {
|
||||
$this->_tooltip = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this hyperlink internal? (to another sheet)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInternal() {
|
||||
return strpos($this->_url, 'sheet://') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_url
|
||||
. $this->_tooltip
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_IValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null);
|
||||
}
|
|
@ -0,0 +1,527 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart
|
||||
{
|
||||
/**
|
||||
* Chart Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name = '';
|
||||
|
||||
/**
|
||||
* Worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_worksheet = null;
|
||||
|
||||
/**
|
||||
* Chart Title
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_title = null;
|
||||
|
||||
/**
|
||||
* Chart Legend
|
||||
*
|
||||
* @var PHPExcel_Chart_Legend
|
||||
*/
|
||||
private $_legend = null;
|
||||
|
||||
/**
|
||||
* X-Axis Label
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_xAxisLabel = null;
|
||||
|
||||
/**
|
||||
* Y-Axis Label
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_yAxisLabel = null;
|
||||
|
||||
/**
|
||||
* Chart Plot Area
|
||||
*
|
||||
* @var PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
private $_plotArea = null;
|
||||
|
||||
/**
|
||||
* Plot Visible Only
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotVisibleOnly = true;
|
||||
|
||||
/**
|
||||
* Display Blanks as
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_displayBlanksAs = '0';
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left Cell Position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_topLeftCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left X-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_topLeftXOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_topLeftYOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Cell Position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_bottomRightCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right X-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_bottomRightXOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_bottomRightYOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart
|
||||
*/
|
||||
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null)
|
||||
{
|
||||
$this->_name = $name;
|
||||
$this->_title = $title;
|
||||
$this->_legend = $legend;
|
||||
$this->_xAxisLabel = $xAxisLabel;
|
||||
$this->_yAxisLabel = $yAxisLabel;
|
||||
$this->_plotArea = $plotArea;
|
||||
$this->_plotVisibleOnly = $plotVisibleOnly;
|
||||
$this->_displayBlanksAs = $displayBlanksAs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getWorksheet() {
|
||||
return $this->_worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Worksheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pValue
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
|
||||
$this->_worksheet = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param PHPExcel_Chart_Title $title
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTitle(PHPExcel_Chart_Title $title) {
|
||||
$this->_title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Legend
|
||||
*
|
||||
* @return PHPExcel_Chart_Legend
|
||||
*/
|
||||
public function getLegend() {
|
||||
return $this->_legend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Legend
|
||||
*
|
||||
* @param PHPExcel_Chart_Legend $legend
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setLegend(PHPExcel_Chart_Legend $legend) {
|
||||
$this->_legend = $legend;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Axis Label
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getXAxisLabel() {
|
||||
return $this->_xAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Axis Label
|
||||
*
|
||||
* @param PHPExcel_Chart_Title $label
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setXAxisLabel(PHPExcel_Chart_Title $label) {
|
||||
$this->_xAxisLabel = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Axis Label
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getYAxisLabel() {
|
||||
return $this->_yAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Axis Label
|
||||
*
|
||||
* @param PHPExcel_Chart_Title $label
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setYAxisLabel(PHPExcel_Chart_Title $label) {
|
||||
$this->_yAxisLabel = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Area
|
||||
*
|
||||
* @return PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
public function getPlotArea() {
|
||||
return $this->_plotArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Visible Only
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPlotVisibleOnly() {
|
||||
return $this->_plotVisibleOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Visible Only
|
||||
*
|
||||
* @param boolean $plotVisibleOnly
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setPlotVisibleOnly($plotVisibleOnly = true) {
|
||||
$this->_plotVisibleOnly = $plotVisibleOnly;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Display Blanks as
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayBlanksAs() {
|
||||
return $this->_displayBlanksAs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Blanks as
|
||||
*
|
||||
* @param string $displayBlanksAs
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setDisplayBlanksAs($displayBlanksAs = '0') {
|
||||
$this->_displayBlanksAs = $displayBlanksAs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the Top Left position for the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
|
||||
$this->_topLeftCellRef = $cell;
|
||||
if (!is_null($xOffset))
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top left position of the chart
|
||||
*
|
||||
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getTopLeftPosition() {
|
||||
return array( 'cell' => $this->_topLeftCellRef,
|
||||
'xOffset' => $this->_topLeftXOffset,
|
||||
'yOffset' => $this->_topLeftYOffset
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the top left of the chart is fixed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopLeftCell() {
|
||||
return $this->_topLeftCellRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Top Left cell position for the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTopLeftCell($cell) {
|
||||
$this->_topLeftCellRef = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTopLeftOffset($xOffset=null,$yOffset=null) {
|
||||
if (!is_null($xOffset))
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftOffset() {
|
||||
return array( 'X' => $this->_topLeftXOffset,
|
||||
'Y' => $this->_topLeftYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setTopLeftXOffset($xOffset) {
|
||||
$this->_topLeftXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftXOffset() {
|
||||
return $this->_topLeftXOffset;
|
||||
}
|
||||
|
||||
public function setTopLeftYOffset($yOffset) {
|
||||
$this->_topLeftYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftYOffset() {
|
||||
return $this->_topLeftYOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Bottom Right position of the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
|
||||
$this->_bottomRightCellRef = $cell;
|
||||
if (!is_null($xOffset))
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom right position of the chart
|
||||
*
|
||||
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getBottomRightPosition() {
|
||||
return array( 'cell' => $this->_bottomRightCellRef,
|
||||
'xOffset' => $this->_bottomRightXOffset,
|
||||
'yOffset' => $this->_bottomRightYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setBottomRightCell($cell) {
|
||||
$this->_bottomRightCellRef = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the bottom right of the chart is fixed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomRightCell() {
|
||||
return $this->_bottomRightCellRef;
|
||||
}
|
||||
|
||||
public function setBottomRightOffset($xOffset=null,$yOffset=null) {
|
||||
if (!is_null($xOffset))
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightOffset() {
|
||||
return array( 'X' => $this->_bottomRightXOffset,
|
||||
'Y' => $this->_bottomRightYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setBottomRightXOffset($xOffset) {
|
||||
$this->_bottomRightXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightXOffset() {
|
||||
return $this->_bottomRightXOffset;
|
||||
}
|
||||
|
||||
public function setBottomRightYOffset($yOffset) {
|
||||
$this->_bottomRightYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightYOffset() {
|
||||
return $this->_bottomRightYOffset;
|
||||
}
|
||||
|
||||
|
||||
public function refresh() {
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_plotArea->refresh($this->_worksheet);
|
||||
}
|
||||
}
|
||||
|
||||
public function render($outputDestination = null) {
|
||||
$libraryName = PHPExcel_Settings::getChartRendererName();
|
||||
if (is_null($libraryName)) {
|
||||
return false;
|
||||
}
|
||||
// Ensure that data series values are up-to-date before we render
|
||||
$this->refresh();
|
||||
|
||||
$libraryPath = PHPExcel_Settings::getChartRendererPath();
|
||||
$includePath = str_replace('\\','/',get_include_path());
|
||||
$rendererPath = str_replace('\\','/',$libraryPath);
|
||||
if (strpos($rendererPath,$includePath) === false) {
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
|
||||
}
|
||||
|
||||
$rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName;
|
||||
$renderer = new $rendererName($this);
|
||||
|
||||
if ($outputDestination == 'php://output') {
|
||||
$outputDestination = null;
|
||||
}
|
||||
return $renderer->render($outputDestination);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,354 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_DataSeries
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_DataSeries
|
||||
{
|
||||
|
||||
const TYPE_BARCHART = 'barChart';
|
||||
const TYPE_BARCHART_3D = 'bar3DChart';
|
||||
const TYPE_LINECHART = 'lineChart';
|
||||
const TYPE_LINECHART_3D = 'line3DChart';
|
||||
const TYPE_AREACHART = 'areaChart';
|
||||
const TYPE_AREACHART_3D = 'area3DChart';
|
||||
const TYPE_PIECHART = 'pieChart';
|
||||
const TYPE_PIECHART_3D = 'pie3DChart';
|
||||
const TYPE_DOUGHTNUTCHART = 'doughnutChart';
|
||||
const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
|
||||
const TYPE_SCATTERCHART = 'scatterChart';
|
||||
const TYPE_SURFACECHART = 'surfaceChart';
|
||||
const TYPE_SURFACECHART_3D = 'surface3DChart';
|
||||
const TYPE_RADARCHART = 'radarChart';
|
||||
const TYPE_BUBBLECHART = 'bubbleChart';
|
||||
const TYPE_STOCKCHART = 'stockChart';
|
||||
|
||||
const GROUPING_CLUSTERED = 'clustered';
|
||||
const GROUPING_STACKED = 'stacked';
|
||||
const GROUPING_PERCENT_STACKED = 'percentStacked';
|
||||
const GROUPING_STANDARD = 'standard';
|
||||
|
||||
const DIRECTION_BAR = 'bar';
|
||||
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
|
||||
const DIRECTION_COL = 'col';
|
||||
const DIRECTION_COLUMN = self::DIRECTION_COL;
|
||||
const DIRECTION_VERTICAL = self::DIRECTION_COL;
|
||||
|
||||
const STYLE_LINEMARKER = 'lineMarker';
|
||||
const STYLE_SMOOTHMARKER = 'smoothMarker';
|
||||
const STYLE_MARKER = 'marker';
|
||||
const STYLE_FILLED = 'filled';
|
||||
|
||||
|
||||
/**
|
||||
* Series Plot Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_plotType = null;
|
||||
|
||||
/**
|
||||
* Plot Grouping Type
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotGrouping = null;
|
||||
|
||||
/**
|
||||
* Plot Direction
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotDirection = null;
|
||||
|
||||
/**
|
||||
* Plot Style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_plotStyle = null;
|
||||
|
||||
/**
|
||||
* Order of plots in Series
|
||||
*
|
||||
* @var array of integer
|
||||
*/
|
||||
private $_plotOrder = array();
|
||||
|
||||
/**
|
||||
* Plot Label
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotLabel = array();
|
||||
|
||||
/**
|
||||
* Plot Category
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotCategory = array();
|
||||
|
||||
/**
|
||||
* Smooth Line
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_smoothLine = null;
|
||||
|
||||
/**
|
||||
* Plot Values
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
private $_plotValues = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null)
|
||||
{
|
||||
$this->_plotType = $plotType;
|
||||
$this->_plotGrouping = $plotGrouping;
|
||||
$this->_plotOrder = $plotOrder;
|
||||
$keys = array_keys($plotValues);
|
||||
$this->_plotValues = $plotValues;
|
||||
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
|
||||
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||
}
|
||||
|
||||
$this->_plotLabel = $plotLabel;
|
||||
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
|
||||
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
|
||||
}
|
||||
$this->_plotCategory = $plotCategory;
|
||||
$this->_smoothLine = $smoothLine;
|
||||
$this->_plotStyle = $plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotType() {
|
||||
return $this->_plotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Type
|
||||
*
|
||||
* @param string $plotType
|
||||
*/
|
||||
public function setPlotType($plotType = '') {
|
||||
$this->_plotType = $plotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Grouping Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotGrouping() {
|
||||
return $this->_plotGrouping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Grouping Type
|
||||
*
|
||||
* @param string $groupingType
|
||||
*/
|
||||
public function setPlotGrouping($groupingType = null) {
|
||||
$this->_plotGrouping = $groupingType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Direction
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotDirection() {
|
||||
return $this->_plotDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Direction
|
||||
*
|
||||
* @param string $plotDirection
|
||||
*/
|
||||
public function setPlotDirection($plotDirection = null) {
|
||||
$this->_plotDirection = $plotDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotOrder() {
|
||||
return $this->_plotOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Labels
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotLabels() {
|
||||
return $this->_plotLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Label by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotLabelByIndex($index) {
|
||||
$keys = array_keys($this->_plotLabel);
|
||||
if (in_array($index,$keys)) {
|
||||
return $this->_plotLabel[$index];
|
||||
} elseif(isset($keys[$index])) {
|
||||
return $this->_plotLabel[$keys[$index]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Categories
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotCategories() {
|
||||
return $this->_plotCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Category by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotCategoryByIndex($index) {
|
||||
$keys = array_keys($this->_plotCategory);
|
||||
if (in_array($index,$keys)) {
|
||||
return $this->_plotCategory[$index];
|
||||
} elseif(isset($keys[$index])) {
|
||||
return $this->_plotCategory[$keys[$index]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlotStyle() {
|
||||
return $this->_plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Style
|
||||
*
|
||||
* @param string $plotStyle
|
||||
*/
|
||||
public function setPlotStyle($plotStyle = null) {
|
||||
$this->_plotStyle = $plotStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotValues() {
|
||||
return $this->_plotValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Values by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function getPlotValuesByIndex($index) {
|
||||
$keys = array_keys($this->_plotValues);
|
||||
if (in_array($index,$keys)) {
|
||||
return $this->_plotValues[$index];
|
||||
} elseif(isset($keys[$index])) {
|
||||
return $this->_plotValues[$keys[$index]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPlotSeriesCount() {
|
||||
return count($this->_plotValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Smooth Line
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSmoothLine() {
|
||||
return $this->_smoothLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Smooth Line
|
||||
*
|
||||
* @param boolean $smoothLine
|
||||
*/
|
||||
public function setSmoothLine($smoothLine = TRUE) {
|
||||
$this->_smoothLine = $smoothLine;
|
||||
}
|
||||
|
||||
public function refresh(PHPExcel_Worksheet $worksheet) {
|
||||
foreach($this->_plotValues as $plotValues) {
|
||||
if ($plotValues !== NULL)
|
||||
$plotValues->refresh($worksheet, TRUE);
|
||||
}
|
||||
foreach($this->_plotLabel as $plotValues) {
|
||||
if ($plotValues !== NULL)
|
||||
$plotValues->refresh($worksheet, TRUE);
|
||||
}
|
||||
foreach($this->_plotCategory as $plotValues) {
|
||||
if ($plotValues !== NULL)
|
||||
$plotValues->refresh($worksheet, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,327 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_DataSeriesValues
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_DataSeriesValues
|
||||
{
|
||||
|
||||
const DATASERIES_TYPE_STRING = 'String';
|
||||
const DATASERIES_TYPE_NUMBER = 'Number';
|
||||
|
||||
private static $_dataTypeValues = array(
|
||||
self::DATASERIES_TYPE_STRING,
|
||||
self::DATASERIES_TYPE_NUMBER,
|
||||
);
|
||||
|
||||
/**
|
||||
* Series Data Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dataType = null;
|
||||
|
||||
/**
|
||||
* Series Data Source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_dataSource = null;
|
||||
|
||||
/**
|
||||
* Format Code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formatCode = null;
|
||||
|
||||
/**
|
||||
* Series Point Marker
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marker = null;
|
||||
|
||||
/**
|
||||
* Point Count (The number of datapoints in the dataseries)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_pointCount = 0;
|
||||
|
||||
/**
|
||||
* Data Values
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
private $_dataValues = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_DataSeriesValues object
|
||||
*/
|
||||
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
|
||||
{
|
||||
$this->setDataType($dataType);
|
||||
$this->_dataSource = $dataSource;
|
||||
$this->_formatCode = $formatCode;
|
||||
$this->_pointCount = $pointCount;
|
||||
$this->_dataValues = $dataValues;
|
||||
$this->_marker = $marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataType() {
|
||||
return $this->_dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Type
|
||||
*
|
||||
* @param string $dataType Datatype of this data series
|
||||
* Typical values are:
|
||||
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
|
||||
* Normally used for axis point values
|
||||
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
|
||||
* Normally used for chart data values
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
|
||||
if (!in_array($dataType, self::$_dataTypeValues)) {
|
||||
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
|
||||
}
|
||||
$this->_dataType = $dataType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Source (formula)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataSource() {
|
||||
return $this->_dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Source (formula)
|
||||
*
|
||||
* @param string $dataSource
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataSource($dataSource = null, $refreshDataValues = true) {
|
||||
$this->_dataSource = $dataSource;
|
||||
|
||||
if ($refreshDataValues) {
|
||||
// TO DO
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Point Marker
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPointMarker() {
|
||||
return $this->_marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Point Marker
|
||||
*
|
||||
* @param string $marker
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setPointMarker($marker = null) {
|
||||
$this->_marker = $marker;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Format Code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode() {
|
||||
return $this->_formatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Format Code
|
||||
*
|
||||
* @param string $formatCode
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setFormatCode($formatCode = null) {
|
||||
$this->_formatCode = $formatCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Point Count
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPointCount() {
|
||||
return $this->_pointCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if the Data Series is a multi-level or a simple series
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMultiLevelSeries() {
|
||||
if (count($this->_dataValues) > 0) {
|
||||
return is_array($this->_dataValues[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the level count of a multi-level Data Series
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function multiLevelCount() {
|
||||
$levelCount = 0;
|
||||
foreach($this->_dataValues as $dataValueSet) {
|
||||
$levelCount = max($levelCount,count($dataValueSet));
|
||||
}
|
||||
return $levelCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Series Data Values
|
||||
*
|
||||
* @return array of mixed
|
||||
*/
|
||||
public function getDataValues() {
|
||||
return $this->_dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first Series Data value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDataValue() {
|
||||
$count = count($this->_dataValues);
|
||||
if ($count == 0) {
|
||||
return null;
|
||||
} elseif ($count == 1) {
|
||||
return $this->_dataValues[0];
|
||||
}
|
||||
return $this->_dataValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Series Data Values
|
||||
*
|
||||
* @param array $dataValues
|
||||
* @param boolean $refreshDataSource
|
||||
* TRUE - refresh the value of _dataSource based on the values of $dataValues
|
||||
* FALSE - don't change the value of _dataSource
|
||||
* @return PHPExcel_Chart_DataSeriesValues
|
||||
*/
|
||||
public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
|
||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
|
||||
$this->_pointCount = count($dataValues);
|
||||
|
||||
if ($refreshDataSource) {
|
||||
// TO DO
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function _stripNulls($var) {
|
||||
return $var !== NULL;
|
||||
}
|
||||
|
||||
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
|
||||
if ($this->_dataSource !== NULL) {
|
||||
$calcEngine = PHPExcel_Calculation::getInstance();
|
||||
$newDataValues = PHPExcel_Calculation::_unwrapResult(
|
||||
$calcEngine->_calculateFormulaValue(
|
||||
'='.$this->_dataSource,
|
||||
NULL,
|
||||
$worksheet->getCell('A1')
|
||||
)
|
||||
);
|
||||
if ($flatten) {
|
||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
||||
foreach($this->_dataValues as &$dataValue) {
|
||||
if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
|
||||
$dataValue = 0.0;
|
||||
}
|
||||
}
|
||||
unset($dataValue);
|
||||
} else {
|
||||
$cellRange = explode('!',$this->_dataSource);
|
||||
if (count($cellRange) > 1) {
|
||||
list(,$cellRange) = $cellRange;
|
||||
}
|
||||
|
||||
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
|
||||
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
|
||||
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
|
||||
} else {
|
||||
$newArray = array_values(array_shift($newDataValues));
|
||||
foreach($newArray as $i => $newDataSet) {
|
||||
$newArray[$i] = array($newDataSet);
|
||||
}
|
||||
|
||||
foreach($newDataValues as $newDataSet) {
|
||||
$i = 0;
|
||||
foreach($newDataSet as $newDataVal) {
|
||||
array_unshift($newArray[$i++],$newDataVal);
|
||||
}
|
||||
}
|
||||
$this->_dataValues = $newArray;
|
||||
}
|
||||
}
|
||||
$this->_pointCount = count($this->_dataValues);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Exception extends Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,417 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Layout
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Layout
|
||||
{
|
||||
/**
|
||||
* layoutTarget
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_layoutTarget = NULL;
|
||||
|
||||
/**
|
||||
* X Mode
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_xMode = NULL;
|
||||
|
||||
/**
|
||||
* Y Mode
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_yMode = NULL;
|
||||
|
||||
/**
|
||||
* X-Position
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_xPos = NULL;
|
||||
|
||||
/**
|
||||
* Y-Position
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_yPos = NULL;
|
||||
|
||||
/**
|
||||
* width
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_width = NULL;
|
||||
|
||||
/**
|
||||
* height
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $_height = NULL;
|
||||
|
||||
/**
|
||||
* show legend key
|
||||
* Specifies that legend keys should be shown in data labels
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showLegendKey = NULL;
|
||||
|
||||
/**
|
||||
* show value
|
||||
* Specifies that the value should be shown in a data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showVal = NULL;
|
||||
|
||||
/**
|
||||
* show category name
|
||||
* Specifies that the category name should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showCatName = NULL;
|
||||
|
||||
/**
|
||||
* show data series name
|
||||
* Specifies that the series name should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showSerName = NULL;
|
||||
|
||||
/**
|
||||
* show percentage
|
||||
* Specifies that the percentage should be shown in the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showPercent = NULL;
|
||||
|
||||
/**
|
||||
* show bubble size
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showBubbleSize = NULL;
|
||||
|
||||
/**
|
||||
* show leader lines
|
||||
* Specifies that leader lines should be shown for the data label.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_showLeaderLines = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function __construct($layout=array())
|
||||
{
|
||||
if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; }
|
||||
if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; }
|
||||
if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; }
|
||||
if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; }
|
||||
if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; }
|
||||
if (isset($layout['w'])) { $this->_width = (float) $layout['w']; }
|
||||
if (isset($layout['h'])) { $this->_height = (float) $layout['h']; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout Target
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLayoutTarget() {
|
||||
return $this->_layoutTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Layout Target
|
||||
*
|
||||
* @param Layout Target $value
|
||||
*/
|
||||
public function setLayoutTarget($value) {
|
||||
$this->_layoutTarget = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXMode() {
|
||||
return $this->_xMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Mode
|
||||
*
|
||||
* @param X-Mode $value
|
||||
*/
|
||||
public function setXMode($value) {
|
||||
$this->_xMode = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Mode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getYMode() {
|
||||
return $this->_xMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Mode
|
||||
*
|
||||
* @param Y-Mode $value
|
||||
*/
|
||||
public function setYMode($value) {
|
||||
$this->_xMode = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Position
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getXPosition() {
|
||||
return $this->_xPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Position
|
||||
*
|
||||
* @param X-Position $value
|
||||
*/
|
||||
public function setXPosition($value) {
|
||||
$this->_xPos = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Position
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getYPosition() {
|
||||
return $this->_yPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Position
|
||||
*
|
||||
* @param Y-Position $value
|
||||
*/
|
||||
public function setYPosition($value) {
|
||||
$this->_yPos = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Width
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Width
|
||||
*
|
||||
* @param Width $value
|
||||
*/
|
||||
public function setWidth($value) {
|
||||
$this->_width = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Height
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Height
|
||||
*
|
||||
* @param Height $value
|
||||
*/
|
||||
public function setHeight($value) {
|
||||
$this->_height = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get show legend key
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowLegendKey() {
|
||||
return $this->_showLegendKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show legend key
|
||||
* Specifies that legend keys should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show legend key
|
||||
*/
|
||||
public function setShowLegendKey($value) {
|
||||
$this->_showLegendKey = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show value
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowVal() {
|
||||
return $this->_showVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show val
|
||||
* Specifies that the value should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show val
|
||||
*/
|
||||
public function setShowVal($value) {
|
||||
$this->_showVal = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show category name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowCatName() {
|
||||
return $this->_showCatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show cat name
|
||||
* Specifies that the category name should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show cat name
|
||||
*/
|
||||
public function setShowCatName($value) {
|
||||
$this->_showCatName = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show data series name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowSerName() {
|
||||
return $this->_showSerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show ser name
|
||||
* Specifies that the series name should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show ser name
|
||||
*/
|
||||
public function setShowSerName($value) {
|
||||
$this->_showSerName = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show percentage
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowPercent() {
|
||||
return $this->_showPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show percentage
|
||||
* Specifies that the percentage should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show percentage
|
||||
*/
|
||||
public function setShowPercent($value) {
|
||||
$this->_showPercent = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show bubble size
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowBubbleSize() {
|
||||
return $this->_showBubbleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show bubble size
|
||||
* Specifies that the bubble size should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show bubble size
|
||||
*/
|
||||
public function setShowBubbleSize($value) {
|
||||
$this->_showBubbleSize = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get show leader lines
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShowLeaderLines() {
|
||||
return $this->_showLeaderLines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set show leader lines
|
||||
* Specifies that leader lines should be shown in data labels.
|
||||
*
|
||||
* @param boolean $value Show leader lines
|
||||
*/
|
||||
public function setShowLeaderLines($value) {
|
||||
$this->_showLeaderLines = $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Legend
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Legend
|
||||
{
|
||||
/** Legend positions */
|
||||
const xlLegendPositionBottom = -4107; // Below the chart.
|
||||
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
|
||||
const xlLegendPositionCustom = -4161; // A custom position.
|
||||
const xlLegendPositionLeft = -4131; // Left of the chart.
|
||||
const xlLegendPositionRight = -4152; // Right of the chart.
|
||||
const xlLegendPositionTop = -4160; // Above the chart.
|
||||
|
||||
const POSITION_RIGHT = 'r';
|
||||
const POSITION_LEFT = 'l';
|
||||
const POSITION_BOTTOM = 'b';
|
||||
const POSITION_TOP = 't';
|
||||
const POSITION_TOPRIGHT = 'tr';
|
||||
|
||||
private static $_positionXLref = array( self::xlLegendPositionBottom => self::POSITION_BOTTOM,
|
||||
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
|
||||
self::xlLegendPositionCustom => '??',
|
||||
self::xlLegendPositionLeft => self::POSITION_LEFT,
|
||||
self::xlLegendPositionRight => self::POSITION_RIGHT,
|
||||
self::xlLegendPositionTop => self::POSITION_TOP
|
||||
);
|
||||
|
||||
/**
|
||||
* Legend position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_position = self::POSITION_RIGHT;
|
||||
|
||||
/**
|
||||
* Allow overlay of other elements?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_overlay = TRUE;
|
||||
|
||||
/**
|
||||
* Legend Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Legend
|
||||
*/
|
||||
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE)
|
||||
{
|
||||
$this->setPosition($position);
|
||||
$this->_layout = $layout;
|
||||
$this->setOverlay($overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an excel string value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPosition() {
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position using an excel string value
|
||||
*
|
||||
* @param string $position
|
||||
*/
|
||||
public function setPosition($position = self::POSITION_RIGHT) {
|
||||
if (!in_array($position,self::$_positionXLref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_position = $position;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legend position as an Excel internal numeric value
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getPositionXL() {
|
||||
return array_search($this->_position,self::$_positionXLref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set legend position using an Excel internal numeric value
|
||||
*
|
||||
* @param number $positionXL
|
||||
*/
|
||||
public function setPositionXL($positionXL = self::xlLegendPositionRight) {
|
||||
if (!array_key_exists($positionXL,self::$_positionXLref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_position = self::$_positionXLref[$positionXL];
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allow overlay of other elements?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOverlay() {
|
||||
return $this->_overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allow overlay of other elements?
|
||||
*
|
||||
* @param boolean $overlay
|
||||
* @return boolean
|
||||
*/
|
||||
public function setOverlay($overlay = FALSE) {
|
||||
if (!is_bool($overlay)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_overlay = $overlay;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_PlotArea
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_PlotArea
|
||||
{
|
||||
/**
|
||||
* PlotArea Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = null;
|
||||
|
||||
/**
|
||||
* Plot Series
|
||||
*
|
||||
* @var array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
private $_plotSeries = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
|
||||
{
|
||||
$this->_layout = $layout;
|
||||
$this->_plotSeries = $plotSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Groups
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroupCount() {
|
||||
return count($this->_plotSeries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Plot Series
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPlotSeriesCount() {
|
||||
$seriesCount = 0;
|
||||
foreach($this->_plotSeries as $plot) {
|
||||
$seriesCount += $plot->getPlotSeriesCount();
|
||||
}
|
||||
return $seriesCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series
|
||||
*
|
||||
* @return array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroup() {
|
||||
return $this->_plotSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Series by Index
|
||||
*
|
||||
* @return PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function getPlotGroupByIndex($index) {
|
||||
return $this->_plotSeries[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Series
|
||||
*
|
||||
* @param array of PHPExcel_Chart_DataSeries
|
||||
*/
|
||||
public function setPlotSeries($plotSeries = array()) {
|
||||
$this->_plotSeries = $plotSeries;
|
||||
}
|
||||
|
||||
public function refresh(PHPExcel_Worksheet $worksheet) {
|
||||
foreach($this->_plotSeries as $plotSeries) {
|
||||
$plotSeries->refresh($worksheet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
ChartDirector
|
||||
http://www.advsofteng.com/cdphp.html
|
||||
|
||||
GraPHPite
|
||||
http://graphpite.sourceforge.net/
|
||||
|
||||
JpGraph
|
||||
http://www.aditus.nu/jpgraph/
|
||||
|
||||
LibChart
|
||||
http://naku.dohcrew.com/libchart/pages/introduction/
|
||||
|
||||
pChart
|
||||
http://pchart.sourceforge.net/
|
||||
|
||||
TeeChart
|
||||
http://www.steema.com/products/teechart/overview.html
|
|
@ -0,0 +1,837 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart_Renderer
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
require_once(PHPExcel_Settings::getChartRendererPath().'/jpgraph.php');
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Renderer_jpgraph
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart_Renderer
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Renderer_jpgraph
|
||||
{
|
||||
private static $_width = 640;
|
||||
|
||||
private static $_height = 480;
|
||||
|
||||
private static $_colourSet = array( 'mediumpurple1', 'palegreen3', 'gold1', 'cadetblue1',
|
||||
'darkmagenta', 'coral', 'dodgerblue3', 'eggplant',
|
||||
'mediumblue', 'magenta', 'sandybrown', 'cyan',
|
||||
'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen',
|
||||
'goldenrod2'
|
||||
);
|
||||
|
||||
private static $_markSet = array( 'diamond' => MARK_DIAMOND,
|
||||
'square' => MARK_SQUARE,
|
||||
'triangle' => MARK_UTRIANGLE,
|
||||
'x' => MARK_X,
|
||||
'star' => MARK_STAR,
|
||||
'dot' => MARK_FILLEDCIRCLE,
|
||||
'dash' => MARK_DTRIANGLE,
|
||||
'circle' => MARK_CIRCLE,
|
||||
'plus' => MARK_CROSS
|
||||
);
|
||||
|
||||
|
||||
private $_chart = null;
|
||||
|
||||
private $_graph = null;
|
||||
|
||||
private static $_plotColour = 0;
|
||||
|
||||
private static $_plotMark = 0;
|
||||
|
||||
|
||||
private function _formatPointMarker($seriesPlot,$markerID) {
|
||||
$plotMarkKeys = array_keys(self::$_markSet);
|
||||
if (is_null($markerID)) {
|
||||
// Use default plot marker (next marker in the series)
|
||||
self::$_plotMark %= count(self::$_markSet);
|
||||
$seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]);
|
||||
} elseif ($markerID !== 'none') {
|
||||
// Use specified plot marker (if it exists)
|
||||
if (isset(self::$_markSet[$markerID])) {
|
||||
$seriesPlot->mark->SetType(self::$_markSet[$markerID]);
|
||||
} else {
|
||||
// If the specified plot marker doesn't exist, use default plot marker (next marker in the series)
|
||||
self::$_plotMark %= count(self::$_markSet);
|
||||
$seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]);
|
||||
}
|
||||
} else {
|
||||
// Hide plot marker
|
||||
$seriesPlot->mark->Hide();
|
||||
}
|
||||
$seriesPlot->mark->SetColor(self::$_colourSet[self::$_plotColour]);
|
||||
$seriesPlot->mark->SetFillColor(self::$_colourSet[self::$_plotColour]);
|
||||
$seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
|
||||
|
||||
return $seriesPlot;
|
||||
} // function _formatPointMarker()
|
||||
|
||||
|
||||
private function _formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '') {
|
||||
$datasetLabelFormatCode = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
|
||||
if (!is_null($datasetLabelFormatCode)) {
|
||||
// Retrieve any label formatting code
|
||||
$datasetLabelFormatCode = stripslashes($datasetLabelFormatCode);
|
||||
}
|
||||
|
||||
$testCurrentIndex = 0;
|
||||
foreach($datasetLabels as $i => $datasetLabel) {
|
||||
if (is_array($datasetLabel)) {
|
||||
if ($rotation == 'bar') {
|
||||
$datasetLabels[$i] = implode(" ",$datasetLabel);
|
||||
} else {
|
||||
$datasetLabel = array_reverse($datasetLabel);
|
||||
$datasetLabels[$i] = implode("\n",$datasetLabel);
|
||||
}
|
||||
} else {
|
||||
// Format labels according to any formatting code
|
||||
if (!is_null($datasetLabelFormatCode)) {
|
||||
$datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode);
|
||||
}
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
return $datasetLabels;
|
||||
} // function _formatDataSetLabels()
|
||||
|
||||
|
||||
private function _percentageSumCalculation($groupID,$seriesCount) {
|
||||
// Adjust our values to a percentage value across all series in the group
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
if ($i == 0) {
|
||||
$sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
} else {
|
||||
$nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
foreach($nextValues as $k => $value) {
|
||||
if (isset($sumValues[$k])) {
|
||||
$sumValues[$k] += $value;
|
||||
} else {
|
||||
$sumValues[$k] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sumValues;
|
||||
} // function _percentageSumCalculation()
|
||||
|
||||
|
||||
private function _percentageAdjustValues($dataValues,$sumValues) {
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
$dataValues[$k] = $dataValue / $sumValues[$k] * 100;
|
||||
}
|
||||
|
||||
return $dataValues;
|
||||
} // function _percentageAdjustValues()
|
||||
|
||||
|
||||
private function _getCaption($captionElement) {
|
||||
// Read any caption
|
||||
$caption = (!is_null($captionElement)) ? $captionElement->getCaption() : NULL;
|
||||
// Test if we have a title caption to display
|
||||
if (!is_null($caption)) {
|
||||
// If we do, it could be a plain string or an array
|
||||
if (is_array($caption)) {
|
||||
// Implode an array to a plain string
|
||||
$caption = implode('',$caption);
|
||||
}
|
||||
}
|
||||
return $caption;
|
||||
} // function _getCaption()
|
||||
|
||||
|
||||
private function _renderTitle() {
|
||||
$title = $this->_getCaption($this->_chart->getTitle());
|
||||
if (!is_null($title)) {
|
||||
$this->_graph->title->Set($title);
|
||||
}
|
||||
} // function _renderTitle()
|
||||
|
||||
|
||||
private function _renderLegend() {
|
||||
$legend = $this->_chart->getLegend();
|
||||
if (!is_null($legend)) {
|
||||
$legendPosition = $legend->getPosition();
|
||||
$legendOverlay = $legend->getOverlay();
|
||||
switch ($legendPosition) {
|
||||
case 'r' :
|
||||
$this->_graph->legend->SetPos(0.01,0.5,'right','center'); // right
|
||||
$this->_graph->legend->SetColumns(1);
|
||||
break;
|
||||
case 'l' :
|
||||
$this->_graph->legend->SetPos(0.01,0.5,'left','center'); // left
|
||||
$this->_graph->legend->SetColumns(1);
|
||||
break;
|
||||
case 't' :
|
||||
$this->_graph->legend->SetPos(0.5,0.01,'center','top'); // top
|
||||
break;
|
||||
case 'b' :
|
||||
$this->_graph->legend->SetPos(0.5,0.99,'center','bottom'); // bottom
|
||||
break;
|
||||
default :
|
||||
$this->_graph->legend->SetPos(0.01,0.01,'right','top'); // top-right
|
||||
$this->_graph->legend->SetColumns(1);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$this->_graph->legend->Hide();
|
||||
}
|
||||
} // function _renderLegend()
|
||||
|
||||
|
||||
private function _renderCartesianPlotArea($type='textlin') {
|
||||
$this->_graph = new Graph(self::$_width,self::$_height);
|
||||
$this->_graph->SetScale($type);
|
||||
|
||||
$this->_renderTitle();
|
||||
|
||||
// Rotate for bar rather than column chart
|
||||
$rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection();
|
||||
$reverse = ($rotation == 'bar') ? true : false;
|
||||
|
||||
$xAxisLabel = $this->_chart->getXAxisLabel();
|
||||
if (!is_null($xAxisLabel)) {
|
||||
$title = $this->_getCaption($xAxisLabel);
|
||||
if (!is_null($title)) {
|
||||
$this->_graph->xaxis->SetTitle($title,'center');
|
||||
$this->_graph->xaxis->title->SetMargin(35);
|
||||
if ($reverse) {
|
||||
$this->_graph->xaxis->title->SetAngle(90);
|
||||
$this->_graph->xaxis->title->SetMargin(90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$yAxisLabel = $this->_chart->getYAxisLabel();
|
||||
if (!is_null($yAxisLabel)) {
|
||||
$title = $this->_getCaption($yAxisLabel);
|
||||
if (!is_null($title)) {
|
||||
$this->_graph->yaxis->SetTitle($title,'center');
|
||||
if ($reverse) {
|
||||
$this->_graph->yaxis->title->SetAngle(0);
|
||||
$this->_graph->yaxis->title->SetMargin(-55);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // function _renderCartesianPlotArea()
|
||||
|
||||
|
||||
private function _renderPiePlotArea($doughnut = False) {
|
||||
$this->_graph = new PieGraph(self::$_width,self::$_height);
|
||||
|
||||
$this->_renderTitle();
|
||||
} // function _renderPiePlotArea()
|
||||
|
||||
|
||||
private function _renderRadarPlotArea() {
|
||||
$this->_graph = new RadarGraph(self::$_width,self::$_height);
|
||||
$this->_graph->SetScale('lin');
|
||||
|
||||
$this->_renderTitle();
|
||||
} // function _renderRadarPlotArea()
|
||||
|
||||
|
||||
private function _renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') {
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
|
||||
$labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
|
||||
if ($labelCount > 0) {
|
||||
$datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
$datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount);
|
||||
$this->_graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount);
|
||||
}
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
|
||||
if ($grouping == 'percentStacked') {
|
||||
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues);
|
||||
}
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
while($k != $testCurrentIndex) {
|
||||
$dataValues[$testCurrentIndex] = null;
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
$seriesPlot = new LinePlot($dataValues);
|
||||
if ($combination) {
|
||||
$seriesPlot->SetBarCenter();
|
||||
}
|
||||
|
||||
if ($filled) {
|
||||
$seriesPlot->SetFilled(true);
|
||||
$seriesPlot->SetColor('black');
|
||||
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
|
||||
} else {
|
||||
// Set the appropriate plot marker
|
||||
$this->_formatPointMarker($seriesPlot,$marker);
|
||||
}
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$seriesPlots[] = $seriesPlot;
|
||||
}
|
||||
|
||||
if ($grouping == 'standard') {
|
||||
$groupPlot = $seriesPlots;
|
||||
} else {
|
||||
$groupPlot = new AccLinePlot($seriesPlots);
|
||||
}
|
||||
$this->_graph->Add($groupPlot);
|
||||
} // function _renderPlotLine()
|
||||
|
||||
|
||||
private function _renderPlotBar($groupID, $dimensions = '2d') {
|
||||
$rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
|
||||
// Rotate for bar rather than column chart
|
||||
if (($groupID == 0) && ($rotation == 'bar')) {
|
||||
$this->_graph->Set90AndMargin();
|
||||
}
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
|
||||
$labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
|
||||
if ($labelCount > 0) {
|
||||
$datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
$datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation);
|
||||
// Rotate for bar rather than column chart
|
||||
if ($rotation == 'bar') {
|
||||
$datasetLabels = array_reverse($datasetLabels);
|
||||
$this->_graph->yaxis->SetPos('max');
|
||||
$this->_graph->yaxis->SetLabelAlign('center','top');
|
||||
$this->_graph->yaxis->SetLabelSide(SIDE_RIGHT);
|
||||
}
|
||||
$this->_graph->xaxis->SetTickLabels($datasetLabels);
|
||||
}
|
||||
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
if ($grouping == 'percentStacked') {
|
||||
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount);
|
||||
}
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($j = 0; $j < $seriesCount; ++$j) {
|
||||
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
|
||||
if ($grouping == 'percentStacked') {
|
||||
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues);
|
||||
}
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
while($k != $testCurrentIndex) {
|
||||
$dataValues[$testCurrentIndex] = null;
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
// Reverse the $dataValues order for bar rather than column chart
|
||||
if ($rotation == 'bar') {
|
||||
$dataValues = array_reverse($dataValues);
|
||||
}
|
||||
$seriesPlot = new BarPlot($dataValues);
|
||||
$seriesPlot->SetColor('black');
|
||||
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
|
||||
if ($dimensions == '3d') {
|
||||
$seriesPlot->SetShadow();
|
||||
}
|
||||
if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) {
|
||||
$dataLabel = '';
|
||||
} else {
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue();
|
||||
}
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$seriesPlots[] = $seriesPlot;
|
||||
}
|
||||
// Reverse the plot order for bar rather than column chart
|
||||
if (($rotation == 'bar') && (!($grouping == 'percentStacked'))) {
|
||||
$seriesPlots = array_reverse($seriesPlots);
|
||||
}
|
||||
|
||||
if ($grouping == 'clustered') {
|
||||
$groupPlot = new GroupBarPlot($seriesPlots);
|
||||
} elseif ($grouping == 'standard') {
|
||||
$groupPlot = new GroupBarPlot($seriesPlots);
|
||||
} else {
|
||||
$groupPlot = new AccBarPlot($seriesPlots);
|
||||
if ($dimensions == '3d') {
|
||||
$groupPlot->SetShadow();
|
||||
}
|
||||
}
|
||||
|
||||
$this->_graph->Add($groupPlot);
|
||||
} // function _renderPlotBar()
|
||||
|
||||
|
||||
private function _renderPlotScatter($groupID,$bubble) {
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
$scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
foreach($dataValuesY as $k => $dataValueY) {
|
||||
$dataValuesY[$k] = $k;
|
||||
}
|
||||
|
||||
$seriesPlot = new ScatterPlot($dataValuesX,$dataValuesY);
|
||||
if ($scatterStyle == 'lineMarker') {
|
||||
$seriesPlot->SetLinkPoints();
|
||||
$seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]);
|
||||
} elseif ($scatterStyle == 'smoothMarker') {
|
||||
$spline = new Spline($dataValuesY,$dataValuesX);
|
||||
list($splineDataY,$splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20);
|
||||
$lplot = new LinePlot($splineDataX,$splineDataY);
|
||||
$lplot->SetColor(self::$_colourSet[self::$_plotColour]);
|
||||
|
||||
$this->_graph->Add($lplot);
|
||||
}
|
||||
|
||||
if ($bubble) {
|
||||
$this->_formatPointMarker($seriesPlot,'dot');
|
||||
$seriesPlot->mark->SetColor('black');
|
||||
$seriesPlot->mark->SetSize($bubbleSize);
|
||||
} else {
|
||||
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
$this->_formatPointMarker($seriesPlot,$marker);
|
||||
}
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
}
|
||||
} // function _renderPlotScatter()
|
||||
|
||||
|
||||
private function _renderPlotRadar($groupID) {
|
||||
$radarStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||
|
||||
$dataValues = array();
|
||||
foreach($dataValuesY as $k => $dataValueY) {
|
||||
$dataValues[$k] = implode(' ',array_reverse($dataValueY));
|
||||
}
|
||||
$tmp = array_shift($dataValues);
|
||||
$dataValues[] = $tmp;
|
||||
$tmp = array_shift($dataValuesX);
|
||||
$dataValuesX[] = $tmp;
|
||||
|
||||
$this->_graph->SetTitles(array_reverse($dataValues));
|
||||
|
||||
$seriesPlot = new RadarPlot(array_reverse($dataValuesX));
|
||||
|
||||
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||
$seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
|
||||
if ($radarStyle == 'filled') {
|
||||
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]);
|
||||
}
|
||||
$this->_formatPointMarker($seriesPlot,$marker);
|
||||
$seriesPlot->SetLegend($dataLabel);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
}
|
||||
} // function _renderPlotRadar()
|
||||
|
||||
|
||||
private function _renderPlotContour($groupID) {
|
||||
$contourStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
|
||||
$dataValues = array();
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
$dataValues[$i] = $dataValuesX;
|
||||
}
|
||||
$seriesPlot = new ContourPlot($dataValues);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
} // function _renderPlotContour()
|
||||
|
||||
|
||||
private function _renderPlotStock($groupID) {
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
|
||||
$seriesPlots = array();
|
||||
|
||||
$dataValues = array();
|
||||
// Loop through each data series in turn
|
||||
for($i = 0; $i < $seriesCount; ++$i) {
|
||||
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
|
||||
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
|
||||
|
||||
foreach($dataValuesX as $j => $dataValueX)
|
||||
$dataValues[$j][$plotOrder[$i]] = $dataValueX;
|
||||
}
|
||||
|
||||
$seriesPlot = new StockPlot($dataValues);
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
} // function _renderPlotStock()
|
||||
|
||||
|
||||
private function _renderAreaChart($groupCount, $dimensions = '2d') {
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotLine($i,True,False,$dimensions);
|
||||
}
|
||||
} // function _renderAreaChart()
|
||||
|
||||
|
||||
private function _renderLineChart($groupCount, $dimensions = '2d') {
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotLine($i,False,False,$dimensions);
|
||||
}
|
||||
} // function _renderLineChart()
|
||||
|
||||
|
||||
private function _renderBarChart($groupCount, $dimensions = '2d') {
|
||||
require_once('jpgraph_bar.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotBar($i,$dimensions);
|
||||
}
|
||||
} // function _renderBarChart()
|
||||
|
||||
|
||||
private function _renderScatterChart($groupCount) {
|
||||
require_once('jpgraph_scatter.php');
|
||||
require_once('jpgraph_regstat.php');
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea('linlin');
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotScatter($i,false);
|
||||
}
|
||||
} // function _renderScatterChart()
|
||||
|
||||
|
||||
private function _renderBubbleChart($groupCount) {
|
||||
require_once('jpgraph_scatter.php');
|
||||
|
||||
$this->_renderCartesianPlotArea('linlin');
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotScatter($i,true);
|
||||
}
|
||||
} // function _renderBubbleChart()
|
||||
|
||||
|
||||
private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) {
|
||||
require_once('jpgraph_pie.php');
|
||||
if ($dimensions == '3d') {
|
||||
require_once('jpgraph_pie3d.php');
|
||||
}
|
||||
|
||||
$this->_renderPiePlotArea($doughnut);
|
||||
|
||||
$iLimit = ($multiplePlots) ? $groupCount : 1;
|
||||
for($groupID = 0; $groupID < $iLimit; ++$groupID) {
|
||||
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||
$exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||
if ($groupID == 0) {
|
||||
$labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
|
||||
if ($labelCount > 0) {
|
||||
$datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues();
|
||||
$datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount);
|
||||
}
|
||||
}
|
||||
|
||||
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||
$seriesPlots = array();
|
||||
// For pie charts, we only display the first series: doughnut charts generally display all series
|
||||
$jLimit = ($multiplePlots) ? $seriesCount : 1;
|
||||
// Loop through each data series in turn
|
||||
for($j = 0; $j < $jLimit; ++$j) {
|
||||
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
|
||||
|
||||
// Fill in any missing values in the $dataValues array
|
||||
$testCurrentIndex = 0;
|
||||
foreach($dataValues as $k => $dataValue) {
|
||||
while($k != $testCurrentIndex) {
|
||||
$dataValues[$testCurrentIndex] = null;
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
++$testCurrentIndex;
|
||||
}
|
||||
|
||||
if ($dimensions == '3d') {
|
||||
$seriesPlot = new PiePlot3D($dataValues);
|
||||
} else {
|
||||
if ($doughnut) {
|
||||
$seriesPlot = new PiePlotC($dataValues);
|
||||
} else {
|
||||
$seriesPlot = new PiePlot($dataValues);
|
||||
}
|
||||
}
|
||||
|
||||
if ($multiplePlots) {
|
||||
$seriesPlot->SetSize(($jLimit-$j) / ($jLimit * 4));
|
||||
}
|
||||
|
||||
if ($doughnut) {
|
||||
$seriesPlot->SetMidColor('white');
|
||||
}
|
||||
|
||||
$seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]);
|
||||
if (count($datasetLabels) > 0)
|
||||
$seriesPlot->SetLabels(array_fill(0,count($datasetLabels),''));
|
||||
if ($dimensions != '3d') {
|
||||
$seriesPlot->SetGuideLines(false);
|
||||
}
|
||||
if ($j == 0) {
|
||||
if ($exploded) {
|
||||
$seriesPlot->ExplodeAll();
|
||||
}
|
||||
$seriesPlot->SetLegends($datasetLabels);
|
||||
}
|
||||
|
||||
$this->_graph->Add($seriesPlot);
|
||||
}
|
||||
}
|
||||
} // function _renderPieChart()
|
||||
|
||||
|
||||
private function _renderRadarChart($groupCount) {
|
||||
require_once('jpgraph_radar.php');
|
||||
|
||||
$this->_renderRadarPlotArea();
|
||||
|
||||
for($groupID = 0; $groupID < $groupCount; ++$groupID) {
|
||||
$this->_renderPlotRadar($groupID);
|
||||
}
|
||||
} // function _renderRadarChart()
|
||||
|
||||
|
||||
private function _renderStockChart($groupCount) {
|
||||
require_once('jpgraph_stock.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($groupID = 0; $groupID < $groupCount; ++$i) {
|
||||
$this->_renderPlotStock($groupID);
|
||||
}
|
||||
} // function _renderStockChart()
|
||||
|
||||
|
||||
private function _renderContourChart($groupCount,$dimensions) {
|
||||
require_once('jpgraph_contour.php');
|
||||
|
||||
$this->_renderCartesianPlotArea('intint');
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$this->_renderPlotContour($i);
|
||||
}
|
||||
} // function _renderContourChart()
|
||||
|
||||
|
||||
private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) {
|
||||
require_once('jpgraph_line.php');
|
||||
require_once('jpgraph_bar.php');
|
||||
require_once('jpgraph_scatter.php');
|
||||
require_once('jpgraph_regstat.php');
|
||||
require_once('jpgraph_line.php');
|
||||
|
||||
$this->_renderCartesianPlotArea();
|
||||
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$dimensions = null;
|
||||
$chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
switch ($chartType) {
|
||||
case 'area3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'areaChart' :
|
||||
$this->_renderPlotLine($i,True,True,$dimensions);
|
||||
break;
|
||||
case 'bar3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'barChart' :
|
||||
$this->_renderPlotBar($i,$dimensions);
|
||||
break;
|
||||
case 'line3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'lineChart' :
|
||||
$this->_renderPlotLine($i,False,True,$dimensions);
|
||||
break;
|
||||
case 'scatterChart' :
|
||||
$this->_renderPlotScatter($i,false);
|
||||
break;
|
||||
case 'bubbleChart' :
|
||||
$this->_renderPlotScatter($i,true);
|
||||
break;
|
||||
default :
|
||||
$this->_graph = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_renderLegend();
|
||||
|
||||
$this->_graph->Stroke($outputDestination);
|
||||
return true;
|
||||
} // function _renderCombinationChart()
|
||||
|
||||
|
||||
public function render($outputDestination) {
|
||||
self::$_plotColour = 0;
|
||||
|
||||
$groupCount = $this->_chart->getPlotArea()->getPlotGroupCount();
|
||||
|
||||
$dimensions = null;
|
||||
if ($groupCount == 1) {
|
||||
$chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
|
||||
} else {
|
||||
$chartTypes = array();
|
||||
for($i = 0; $i < $groupCount; ++$i) {
|
||||
$chartTypes[] = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
|
||||
}
|
||||
$chartTypes = array_unique($chartTypes);
|
||||
if (count($chartTypes) == 1) {
|
||||
$chartType = array_pop($chartTypes);
|
||||
} elseif (count($chartTypes) == 0) {
|
||||
echo 'Chart is not yet implemented<br />';
|
||||
return false;
|
||||
} else {
|
||||
return $this->_renderCombinationChart($groupCount,$dimensions,$outputDestination);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($chartType) {
|
||||
case 'area3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'areaChart' :
|
||||
$this->_renderAreaChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'bar3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'barChart' :
|
||||
$this->_renderBarChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'line3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'lineChart' :
|
||||
$this->_renderLineChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'pie3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'pieChart' :
|
||||
$this->_renderPieChart($groupCount,$dimensions,False,False);
|
||||
break;
|
||||
case 'doughnut3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'doughnutChart' :
|
||||
$this->_renderPieChart($groupCount,$dimensions,True,True);
|
||||
break;
|
||||
case 'scatterChart' :
|
||||
$this->_renderScatterChart($groupCount);
|
||||
break;
|
||||
case 'bubbleChart' :
|
||||
$this->_renderBubbleChart($groupCount);
|
||||
break;
|
||||
case 'radarChart' :
|
||||
$this->_renderRadarChart($groupCount);
|
||||
break;
|
||||
case 'surface3DChart' :
|
||||
$dimensions = '3d';
|
||||
case 'surfaceChart' :
|
||||
$this->_renderContourChart($groupCount,$dimensions);
|
||||
break;
|
||||
case 'stockChart' :
|
||||
$this->_renderStockChart($groupCount,$dimensions);
|
||||
break;
|
||||
default :
|
||||
echo $chartType.' is not yet implemented<br />';
|
||||
return false;
|
||||
}
|
||||
$this->_renderLegend();
|
||||
|
||||
$this->_graph->Stroke($outputDestination);
|
||||
return true;
|
||||
} // function render()
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Renderer_jpgraph
|
||||
*/
|
||||
public function __construct(PHPExcel_Chart $chart)
|
||||
{
|
||||
$this->_graph = null;
|
||||
$this->_chart = $chart;
|
||||
} // function __construct()
|
||||
|
||||
} // PHPExcel_Chart_Renderer_jpgraph
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart_Title
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart_Title
|
||||
{
|
||||
|
||||
/**
|
||||
* Title Caption
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_caption = null;
|
||||
|
||||
/**
|
||||
* Title Layout
|
||||
*
|
||||
* @var PHPExcel_Chart_Layout
|
||||
*/
|
||||
private $_layout = null;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart_Title
|
||||
*/
|
||||
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
|
||||
{
|
||||
$this->_caption = $caption;
|
||||
$this->_layout = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get caption
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCaption() {
|
||||
return $this->_caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set caption
|
||||
*
|
||||
* @param string $caption
|
||||
*/
|
||||
public function setCaption($caption = null) {
|
||||
$this->_caption = $caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Layout
|
||||
*
|
||||
* @return PHPExcel_Chart_Layout
|
||||
*/
|
||||
public function getLayout() {
|
||||
return $this->_layout;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,317 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Comment
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Author
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_author;
|
||||
|
||||
/**
|
||||
* Rich text comment
|
||||
*
|
||||
* @var PHPExcel_RichText
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_width = '96pt';
|
||||
|
||||
/**
|
||||
* Left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marginLeft = '59.25pt';
|
||||
|
||||
/**
|
||||
* Top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marginTop = '1.5pt';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_visible = false;
|
||||
|
||||
/**
|
||||
* Comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_height = '55.5pt';
|
||||
|
||||
/**
|
||||
* Comment fill color
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_fillColor;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Comment
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_author = 'Author';
|
||||
$this->_text = new PHPExcel_RichText();
|
||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor() {
|
||||
return $this->_author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Author
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setAuthor($pValue = '') {
|
||||
$this->_author = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich text comment
|
||||
*
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich text comment
|
||||
*
|
||||
* @param PHPExcel_RichText $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setText(PHPExcel_RichText $pValue) {
|
||||
$this->_text = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setWidth($value = '96pt') {
|
||||
$this->_width = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setHeight($value = '55.5pt') {
|
||||
$this->_height = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMarginLeft() {
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setMarginLeft($value = '59.25pt') {
|
||||
$this->_marginLeft = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMarginTop() {
|
||||
return $this->_marginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setMarginTop($value = '1.5pt') {
|
||||
$this->_marginTop = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the comment visible by default?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getVisible() {
|
||||
return $this->_visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment default visibility
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setVisible($value = false) {
|
||||
$this->_visible = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill color
|
||||
*
|
||||
* @return PHPExcel_Style_Color
|
||||
*/
|
||||
public function getFillColor() {
|
||||
return $this->_fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
|
||||
$this->_alignment = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alignment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlignment() {
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_author
|
||||
. $this->_text->getHashCode()
|
||||
. $this->_width
|
||||
. $this->_height
|
||||
. $this->_marginLeft
|
||||
. $this->_marginTop
|
||||
. ($this->_visible ? 1 : 0)
|
||||
. $this->_fillColor->getHashCode()
|
||||
. $this->_alignment
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,588 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_DocumentProperties
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_DocumentProperties
|
||||
{
|
||||
/** constants */
|
||||
const PROPERTY_TYPE_BOOLEAN = 'b';
|
||||
const PROPERTY_TYPE_INTEGER = 'i';
|
||||
const PROPERTY_TYPE_FLOAT = 'f';
|
||||
const PROPERTY_TYPE_DATE = 'd';
|
||||
const PROPERTY_TYPE_STRING = 's';
|
||||
const PROPERTY_TYPE_UNKNOWN = 'u';
|
||||
|
||||
|
||||
/**
|
||||
* Creator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_creator = 'Unknown Creator';
|
||||
|
||||
/**
|
||||
* LastModifiedBy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Created
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_title = 'Untitled Spreadsheet';
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_description = '';
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_subject = '';
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_keywords = '';
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category = '';
|
||||
|
||||
/**
|
||||
* Manager
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_manager = '';
|
||||
|
||||
/**
|
||||
* Company
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_company = 'Microsoft Corporation';
|
||||
|
||||
/**
|
||||
* Custom Properties
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_customProperties = array();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_lastModifiedBy = $this->_creator;
|
||||
$this->_created = time();
|
||||
$this->_modified = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator() {
|
||||
return $this->_creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCreator($pValue = '') {
|
||||
$this->_creator = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy() {
|
||||
return $this->_lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '') {
|
||||
$this->_lastModifiedBy = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getCreated() {
|
||||
return $this->_created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null) {
|
||||
if ($pValue === NULL) {
|
||||
$pValue = time();
|
||||
} elseif (is_string($pValue)) {
|
||||
if (is_numeric($pValue)) {
|
||||
$pValue = intval($pValue);
|
||||
} else {
|
||||
$pValue = strtotime($pValue);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_created = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getModified() {
|
||||
return $this->_modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null) {
|
||||
if ($pValue === NULL) {
|
||||
$pValue = time();
|
||||
} elseif (is_string($pValue)) {
|
||||
if (is_numeric($pValue)) {
|
||||
$pValue = intval($pValue);
|
||||
} else {
|
||||
$pValue = strtotime($pValue);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_modified = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setTitle($pValue = '') {
|
||||
$this->_title = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
$this->_description = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject() {
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setSubject($pValue = '') {
|
||||
$this->_subject = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords() {
|
||||
return $this->_keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setKeywords($pValue = '') {
|
||||
$this->_keywords = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCategory($pValue = '') {
|
||||
$this->_category = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Company
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany() {
|
||||
return $this->_company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Company
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCompany($pValue = '') {
|
||||
$this->_company = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getManager() {
|
||||
return $this->_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Manager
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setManager($pValue = '') {
|
||||
$this->_manager = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List of Custom Property Names
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCustomProperties() {
|
||||
return array_keys($this->_customProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Custom Property is defined
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return boolean
|
||||
*/
|
||||
public function isCustomPropertySet($propertyName) {
|
||||
return isset($this->_customProperties[$propertyName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Custom Property Value
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomPropertyValue($propertyName) {
|
||||
if (isset($this->_customProperties[$propertyName])) {
|
||||
return $this->_customProperties[$propertyName]['value'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Custom Property Type
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomPropertyType($propertyName) {
|
||||
if (isset($this->_customProperties[$propertyName])) {
|
||||
return $this->_customProperties[$propertyName]['type'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a Custom Property
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @param mixed $propertyValue
|
||||
* @param string $propertyType
|
||||
* 'i' : Integer
|
||||
* 'f' : Floating Point
|
||||
* 's' : String
|
||||
* 'd' : Date/Time
|
||||
* 'b' : Boolean
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
|
||||
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
|
||||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN)))) {
|
||||
if ($propertyValue === NULL) {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
} elseif (is_float($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
||||
} elseif(is_int($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
||||
} elseif (is_bool($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
||||
} else {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function convertProperty($propertyValue,$propertyType) {
|
||||
switch ($propertyType) {
|
||||
case 'empty' : // Empty
|
||||
return '';
|
||||
break;
|
||||
case 'null' : // Null
|
||||
return NULL;
|
||||
break;
|
||||
case 'i1' : // 1-Byte Signed Integer
|
||||
case 'i2' : // 2-Byte Signed Integer
|
||||
case 'i4' : // 4-Byte Signed Integer
|
||||
case 'i8' : // 8-Byte Signed Integer
|
||||
case 'int' : // Integer
|
||||
return (int) $propertyValue;
|
||||
break;
|
||||
case 'ui1' : // 1-Byte Unsigned Integer
|
||||
case 'ui2' : // 2-Byte Unsigned Integer
|
||||
case 'ui4' : // 4-Byte Unsigned Integer
|
||||
case 'ui8' : // 8-Byte Unsigned Integer
|
||||
case 'uint' : // Unsigned Integer
|
||||
return abs((int) $propertyValue);
|
||||
break;
|
||||
case 'r4' : // 4-Byte Real Number
|
||||
case 'r8' : // 8-Byte Real Number
|
||||
case 'decimal' : // Decimal
|
||||
return (float) $propertyValue;
|
||||
break;
|
||||
case 'lpstr' : // LPSTR
|
||||
case 'lpwstr' : // LPWSTR
|
||||
case 'bstr' : // Basic String
|
||||
return $propertyValue;
|
||||
break;
|
||||
case 'date' : // Date and Time
|
||||
case 'filetime' : // File Time
|
||||
return strtotime($propertyValue);
|
||||
break;
|
||||
case 'bool' : // Boolean
|
||||
return ($propertyValue == 'true') ? True : False;
|
||||
break;
|
||||
case 'cy' : // Currency
|
||||
case 'error' : // Error Status Code
|
||||
case 'vector' : // Vector
|
||||
case 'array' : // Array
|
||||
case 'blob' : // Binary Blob
|
||||
case 'oblob' : // Binary Blob Object
|
||||
case 'stream' : // Binary Stream
|
||||
case 'ostream' : // Binary Stream Object
|
||||
case 'storage' : // Binary Storage
|
||||
case 'ostorage' : // Binary Storage Object
|
||||
case 'vstream' : // Binary Versioned Stream
|
||||
case 'clsid' : // Class ID
|
||||
case 'cf' : // Clipboard Data
|
||||
return $propertyValue;
|
||||
break;
|
||||
}
|
||||
return $propertyValue;
|
||||
}
|
||||
|
||||
public static function convertPropertyType($propertyType) {
|
||||
switch ($propertyType) {
|
||||
case 'i1' : // 1-Byte Signed Integer
|
||||
case 'i2' : // 2-Byte Signed Integer
|
||||
case 'i4' : // 4-Byte Signed Integer
|
||||
case 'i8' : // 8-Byte Signed Integer
|
||||
case 'int' : // Integer
|
||||
case 'ui1' : // 1-Byte Unsigned Integer
|
||||
case 'ui2' : // 2-Byte Unsigned Integer
|
||||
case 'ui4' : // 4-Byte Unsigned Integer
|
||||
case 'ui8' : // 8-Byte Unsigned Integer
|
||||
case 'uint' : // Unsigned Integer
|
||||
return self::PROPERTY_TYPE_INTEGER;
|
||||
break;
|
||||
case 'r4' : // 4-Byte Real Number
|
||||
case 'r8' : // 8-Byte Real Number
|
||||
case 'decimal' : // Decimal
|
||||
return self::PROPERTY_TYPE_FLOAT;
|
||||
break;
|
||||
case 'empty' : // Empty
|
||||
case 'null' : // Null
|
||||
case 'lpstr' : // LPSTR
|
||||
case 'lpwstr' : // LPWSTR
|
||||
case 'bstr' : // Basic String
|
||||
return self::PROPERTY_TYPE_STRING;
|
||||
break;
|
||||
case 'date' : // Date and Time
|
||||
case 'filetime' : // File Time
|
||||
return self::PROPERTY_TYPE_DATE;
|
||||
break;
|
||||
case 'bool' : // Boolean
|
||||
return self::PROPERTY_TYPE_BOOLEAN;
|
||||
break;
|
||||
case 'cy' : // Currency
|
||||
case 'error' : // Error Status Code
|
||||
case 'vector' : // Vector
|
||||
case 'array' : // Array
|
||||
case 'blob' : // Binary Blob
|
||||
case 'oblob' : // Binary Blob Object
|
||||
case 'stream' : // Binary Stream
|
||||
case 'ostream' : // Binary Stream Object
|
||||
case 'storage' : // Binary Storage
|
||||
case 'ostorage' : // Binary Storage Object
|
||||
case 'vstream' : // Binary Versioned Stream
|
||||
case 'clsid' : // Class ID
|
||||
case 'cf' : // Clipboard Data
|
||||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_DocumentSecurity
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_DocumentSecurity
|
||||
{
|
||||
/**
|
||||
* LockRevision
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockRevision;
|
||||
|
||||
/**
|
||||
* LockStructure
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockStructure;
|
||||
|
||||
/**
|
||||
* LockWindows
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockWindows;
|
||||
|
||||
/**
|
||||
* RevisionsPassword
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_revisionsPassword;
|
||||
|
||||
/**
|
||||
* WorkbookPassword
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_workbookPassword;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_DocumentSecurity
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_lockRevision = false;
|
||||
$this->_lockStructure = false;
|
||||
$this->_lockWindows = false;
|
||||
$this->_revisionsPassword = '';
|
||||
$this->_workbookPassword = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is some sort of dcument security enabled?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isSecurityEnabled() {
|
||||
return $this->_lockRevision ||
|
||||
$this->_lockStructure ||
|
||||
$this->_lockWindows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockRevision
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockRevision() {
|
||||
return $this->_lockRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockRevision
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockRevision($pValue = false) {
|
||||
$this->_lockRevision = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockStructure
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockStructure() {
|
||||
return $this->_lockStructure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockStructure
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockStructure($pValue = false) {
|
||||
$this->_lockStructure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockWindows
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockWindows() {
|
||||
return $this->_lockWindows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockWindows
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockWindows($pValue = false) {
|
||||
$this->_lockWindows = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RevisionsPassword (hashed)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getRevisionsPassword() {
|
||||
return $this->_revisionsPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RevisionsPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
|
||||
if (!$pAlreadyHashed) {
|
||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->_revisionsPassword = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WorkbookPassword (hashed)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getWorkbookPassword() {
|
||||
return $this->_workbookPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set WorkbookPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
|
||||
if (!$pAlreadyHashed) {
|
||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->_workbookPassword = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Exception extends Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_HashTable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_HashTable
|
||||
{
|
||||
/**
|
||||
* HashTable elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_items = array();
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_keyMap = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_HashTable
|
||||
*
|
||||
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($pSource = null)
|
||||
{
|
||||
if ($pSource !== NULL) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} else if (!is_array($pSource)) {
|
||||
throw new Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable item
|
||||
*
|
||||
* @param PHPExcel_IComparable $pSource Item to add
|
||||
* @throws Exception
|
||||
*/
|
||||
public function add(PHPExcel_IComparable $pSource = null) {
|
||||
$hash = $pSource->getHashCode();
|
||||
if (!isset($this->_items[$hash])) {
|
||||
$this->_items[$hash] = $pSource;
|
||||
$this->_keyMap[count($this->_items) - 1] = $hash;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
* @param PHPExcel_IComparable $pSource Item to remove
|
||||
* @throws Exception
|
||||
*/
|
||||
public function remove(PHPExcel_IComparable $pSource = null) {
|
||||
$hash = $pSource->getHashCode();
|
||||
if (isset($this->_items[$hash])) {
|
||||
unset($this->_items[$hash]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $hash) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPExcel_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return PHPExcel_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
*
|
||||
* @return PHPExcel_IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_IComparable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_IOFactory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_IOFactory
|
||||
{
|
||||
/**
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $_searchLocations = array(
|
||||
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
|
||||
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
|
||||
);
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
'OOCalc',
|
||||
'SYLK',
|
||||
'Gnumeric',
|
||||
'HTML',
|
||||
'CSV',
|
||||
);
|
||||
|
||||
/**
|
||||
* Private constructor for PHPExcel_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
} // function getSearchLocations()
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param array $value
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
|
||||
}
|
||||
} // function setSearchLocations()
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPExcel/Writer/{0}.php
|
||||
* @param string $classname Example: PHPExcel_Writer_{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
} // function addSearchLocation()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Writer_IWriter
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param PHPExcel $phpExcel
|
||||
* @param string $writerType Example: Excel2007
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IWriter';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||
|
||||
$instance = new $className($phpExcel);
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
|
||||
} // function createWriter()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $readerType Example: Excel2007
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createReader($readerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IReader';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||
|
||||
$instance = new $className();
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
||||
} // function createReader()
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFileName The name of the spreadsheet file
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function load($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
return $reader->load($pFilename);
|
||||
} // function load()
|
||||
|
||||
/**
|
||||
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFileName The name of the spreadsheet file to identify
|
||||
* @return string
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function identify($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
$className = get_class($reader);
|
||||
$classType = explode('_',$className);
|
||||
unset($reader);
|
||||
return array_pop($classType);
|
||||
} // function identify()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFileName The name of the spreadsheet file
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createReaderForFile($pFilename) {
|
||||
|
||||
// First, lucky guess by inspecting file extension
|
||||
$pathinfo = pathinfo($pFilename);
|
||||
|
||||
$extensionType = NULL;
|
||||
if (isset($pathinfo['extension'])) {
|
||||
switch (strtolower($pathinfo['extension'])) {
|
||||
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
|
||||
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
|
||||
case 'xltx': // Excel (OfficeOpenXML) Template
|
||||
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
|
||||
$extensionType = 'Excel2007';
|
||||
break;
|
||||
case 'xls': // Excel (BIFF) Spreadsheet
|
||||
case 'xlt': // Excel (BIFF) Template
|
||||
$extensionType = 'Excel5';
|
||||
break;
|
||||
case 'ods': // Open/Libre Offic Calc
|
||||
case 'ots': // Open/Libre Offic Calc Template
|
||||
$extensionType = 'OOCalc';
|
||||
break;
|
||||
case 'slk':
|
||||
$extensionType = 'SYLK';
|
||||
break;
|
||||
case 'xml': // Excel 2003 SpreadSheetML
|
||||
$extensionType = 'Excel2003XML';
|
||||
break;
|
||||
case 'gnumeric':
|
||||
$extensionType = 'Gnumeric';
|
||||
break;
|
||||
case 'htm':
|
||||
case 'html':
|
||||
$extensionType = 'HTML';
|
||||
break;
|
||||
case 'csv':
|
||||
// Do nothing
|
||||
// We must not try to use CSV reader since it loads
|
||||
// all files including Excel files etc.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($extensionType !== NULL) {
|
||||
$reader = self::createReader($extensionType);
|
||||
// Let's see if we are lucky
|
||||
if (isset($reader) && $reader->canRead($pFilename)) {
|
||||
return $reader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we reach here then "lucky guess" didn't give any result
|
||||
// Try walking through all the options in self::$_autoResolveClasses
|
||||
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
||||
// Ignore our original guess, we know that won't work
|
||||
if ($autoResolveClass !== $extensionType) {
|
||||
$reader = self::createReader($autoResolveClass);
|
||||
if ($reader->canRead($pFilename)) {
|
||||
return $reader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
|
||||
} // function createReaderForFile()
|
||||
}
|
|
@ -0,0 +1,245 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_NamedRange
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_NamedRange
|
||||
{
|
||||
/**
|
||||
* Range name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name;
|
||||
|
||||
/**
|
||||
* Worksheet on which the named range can be resolved
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_worksheet;
|
||||
|
||||
/**
|
||||
* Range of the referenced cells
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_range;
|
||||
|
||||
/**
|
||||
* Is the named range local? (i.e. can only be used on $this->_worksheet)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_localOnly;
|
||||
|
||||
/**
|
||||
* Scope
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_scope;
|
||||
|
||||
/**
|
||||
* Create a new NamedRange
|
||||
*
|
||||
* @param string $pName
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @param string $pRange
|
||||
* @param bool $pLocalOnly
|
||||
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
||||
*/
|
||||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||
{
|
||||
// Validate data
|
||||
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
|
||||
throw new Exception('Parameters can not be null.');
|
||||
}
|
||||
|
||||
// Set local members
|
||||
$this->_name = $pName;
|
||||
$this->_worksheet = $pWorksheet;
|
||||
$this->_range = $pRange;
|
||||
$this->_localOnly = $pLocalOnly;
|
||||
$this->_scope = ($pLocalOnly == true) ?
|
||||
(($pScope == null) ? $pWorksheet : $pScope) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setName($value = null) {
|
||||
if ($value !== NULL) {
|
||||
// Old title
|
||||
$oldTitle = $this->_name;
|
||||
|
||||
// Re-attach
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
|
||||
}
|
||||
$this->_name = $value;
|
||||
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->addNamedRange($this);
|
||||
}
|
||||
|
||||
// New title
|
||||
$newTitle = $this->_name;
|
||||
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getWorksheet() {
|
||||
return $this->_worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set worksheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setWorksheet(PHPExcel_Worksheet $value = null) {
|
||||
if ($value !== NULL) {
|
||||
$this->_worksheet = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get range
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRange() {
|
||||
return $this->_range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set range
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setRange($value = null) {
|
||||
if ($value !== NULL) {
|
||||
$this->_range = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localOnly
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getLocalOnly() {
|
||||
return $this->_localOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set localOnly
|
||||
*
|
||||
* @param bool $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setLocalOnly($value = false) {
|
||||
$this->_localOnly = $value;
|
||||
$this->_scope = $value ? $this->_worksheet : null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scope
|
||||
*
|
||||
* @return PHPExcel_Worksheet|null
|
||||
*/
|
||||
public function getScope() {
|
||||
return $this->_scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set scope
|
||||
*
|
||||
* @param PHPExcel_Worksheet|null $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setScope(PHPExcel_Worksheet $value = null) {
|
||||
$this->_scope = $value;
|
||||
$this->_localOnly = ($value == null) ? false : true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a named range to a regular cell range
|
||||
*
|
||||
* @param string $pNamedRange Named range
|
||||
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
|
||||
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Abstract
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Read data only?
|
||||
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
|
||||
* or whether it should read both data and formatting
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_readDataOnly = FALSE;
|
||||
|
||||
/**
|
||||
* Read charts that are defined in the workbook?
|
||||
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_includeCharts = FALSE;
|
||||
|
||||
/**
|
||||
* Restrict which sheets should be loaded?
|
||||
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
|
||||
*
|
||||
* @var array of string
|
||||
*/
|
||||
protected $_loadSheetsOnly = NULL;
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter instance
|
||||
*
|
||||
* @var PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
protected $_readFilter = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Read data only?
|
||||
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
|
||||
* If false (the default) it will read data and formatting.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getReadDataOnly() {
|
||||
return $this->_readDataOnly;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set read data only
|
||||
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
|
||||
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setReadDataOnly($pValue = FALSE) {
|
||||
$this->_readDataOnly = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read charts in workbook?
|
||||
* If this is true, then the Reader will include any charts that exist in the workbook.
|
||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||
* If false (the default) it will ignore any charts defined in the workbook file.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIncludeCharts() {
|
||||
return $this->_includeCharts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set read charts in workbook
|
||||
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||
* Set to false (the default) to discard charts.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setIncludeCharts($pValue = FALSE) {
|
||||
$this->_includeCharts = (boolean) $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get which sheets to load
|
||||
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
|
||||
* indicating that all worksheets in the workbook should be loaded.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLoadSheetsOnly()
|
||||
{
|
||||
return $this->_loadSheetsOnly;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set which sheets to load
|
||||
*
|
||||
* @param mixed $value
|
||||
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
|
||||
* If NULL, then it tells the Reader to read all worksheets in the workbook
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setLoadSheetsOnly($value = NULL)
|
||||
{
|
||||
$this->_loadSheetsOnly = is_array($value) ?
|
||||
$value : array($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set all sheets to load
|
||||
* Tells the Reader to load all worksheets from the workbook.
|
||||
*
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setLoadAllSheets()
|
||||
{
|
||||
$this->_loadSheetsOnly = NULL;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read filter
|
||||
*
|
||||
* @return PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
public function getReadFilter() {
|
||||
return $this->_readFilter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set read filter
|
||||
*
|
||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||
* @return PHPExcel_Reader_IReader
|
||||
*/
|
||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
||||
$this->_readFilter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,473 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_CSV
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Delimiter
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_delimiter = ',';
|
||||
|
||||
/**
|
||||
* Enclosure
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_enclosure = '"';
|
||||
|
||||
/**
|
||||
* Line ending
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_lineEnding = PHP_EOL;
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Load rows contiguously
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_contiguous = false;
|
||||
|
||||
|
||||
/**
|
||||
* Row counter for loading rows contiguously
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_contiguousRow = -1;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @access public
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
return true;
|
||||
} // function canRead()
|
||||
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @access public
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'UTF-8')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
} // function setInputEncoding()
|
||||
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
} // function getInputEncoding()
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
* @access public
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Open file
|
||||
$fileHandle = fopen($pFilename, 'r');
|
||||
if ($fileHandle === false) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
|
||||
}
|
||||
|
||||
// Skip BOM, if any
|
||||
switch ($this->_inputEncoding) {
|
||||
case 'UTF-8':
|
||||
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
|
||||
fseek($fileHandle, 3) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-16LE':
|
||||
fgets($fileHandle, 3) == "\xFF\xFE" ?
|
||||
fseek($fileHandle, 2) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-16BE':
|
||||
fgets($fileHandle, 3) == "\xFE\xFF" ?
|
||||
fseek($fileHandle, 2) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-32LE':
|
||||
fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
||||
fseek($fileHandle, 4) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-32BE':
|
||||
fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
||||
fseek($fileHandle, 4) : fseek($fileHandle, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||
$worksheetInfo[0]['totalRows'] = 0;
|
||||
$worksheetInfo[0]['totalColumns'] = 0;
|
||||
|
||||
// Loop through each line of the file in turn
|
||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
||||
$worksheetInfo[0]['totalRows']++;
|
||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @access public
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
} // function load()
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @access public
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Create new PHPExcel
|
||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$sheet = $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||
|
||||
$lineEnding = ini_get('auto_detect_line_endings');
|
||||
ini_set('auto_detect_line_endings', true);
|
||||
|
||||
// Open file
|
||||
$fileHandle = fopen($pFilename, 'r');
|
||||
if ($fileHandle === false) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open file $pFilename for reading.");
|
||||
}
|
||||
|
||||
// Skip BOM, if any
|
||||
switch ($this->_inputEncoding) {
|
||||
case 'UTF-8':
|
||||
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
|
||||
fseek($fileHandle, 3) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-16LE':
|
||||
fgets($fileHandle, 3) == "\xFF\xFE" ?
|
||||
fseek($fileHandle, 2) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-16BE':
|
||||
fgets($fileHandle, 3) == "\xFE\xFF" ?
|
||||
fseek($fileHandle, 2) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-32LE':
|
||||
fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
||||
fseek($fileHandle, 4) : fseek($fileHandle, 0);
|
||||
break;
|
||||
case 'UTF-32BE':
|
||||
fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
||||
fseek($fileHandle, 4) : fseek($fileHandle, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$escapeEnclosures = array( "\\" . $this->_enclosure,
|
||||
$this->_enclosure . $this->_enclosure
|
||||
);
|
||||
|
||||
// Set our starting row based on whether we're in contiguous mode or not
|
||||
$currentRow = 1;
|
||||
if ($this->_contiguous) {
|
||||
$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
|
||||
}
|
||||
|
||||
// Loop through each line of the file in turn
|
||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
||||
$columnLetter = 'A';
|
||||
foreach($rowData as $rowDatum) {
|
||||
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
|
||||
// Unescape enclosures
|
||||
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
|
||||
|
||||
// Convert encoding if necessary
|
||||
if ($this->_inputEncoding !== 'UTF-8') {
|
||||
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
|
||||
}
|
||||
|
||||
// Set cell value
|
||||
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
|
||||
}
|
||||
++$columnLetter;
|
||||
}
|
||||
++$currentRow;
|
||||
}
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
if ($this->_contiguous) {
|
||||
$this->_contiguousRow = $currentRow;
|
||||
}
|
||||
|
||||
ini_set('auto_detect_line_endings', $lineEnding);
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
} // function loadIntoExisting()
|
||||
|
||||
|
||||
/**
|
||||
* Get delimiter
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter() {
|
||||
return $this->_delimiter;
|
||||
} // function getDelimiter()
|
||||
|
||||
|
||||
/**
|
||||
* Set delimiter
|
||||
*
|
||||
* @access public
|
||||
* @param string $pValue Delimiter, defaults to ,
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setDelimiter($pValue = ',') {
|
||||
$this->_delimiter = $pValue;
|
||||
return $this;
|
||||
} // function setDelimiter()
|
||||
|
||||
|
||||
/**
|
||||
* Get enclosure
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure() {
|
||||
return $this->_enclosure;
|
||||
} // function getEnclosure()
|
||||
|
||||
|
||||
/**
|
||||
* Set enclosure
|
||||
*
|
||||
* @access public
|
||||
* @param string $pValue Enclosure, defaults to "
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setEnclosure($pValue = '"') {
|
||||
if ($pValue == '') {
|
||||
$pValue = '"';
|
||||
}
|
||||
$this->_enclosure = $pValue;
|
||||
return $this;
|
||||
} // function setEnclosure()
|
||||
|
||||
|
||||
/**
|
||||
* Get line ending
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getLineEnding() {
|
||||
return $this->_lineEnding;
|
||||
} // function getLineEnding()
|
||||
|
||||
|
||||
/**
|
||||
* Set line ending
|
||||
*
|
||||
* @access public
|
||||
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setLineEnding($pValue = PHP_EOL) {
|
||||
$this->_lineEnding = $pValue;
|
||||
return $this;
|
||||
} // function setLineEnding()
|
||||
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
} // function getSheetIndex()
|
||||
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @access public
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
} // function setSheetIndex()
|
||||
|
||||
|
||||
/**
|
||||
* Set Contiguous
|
||||
*
|
||||
* @access public
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setContiguous($contiguous = false)
|
||||
{
|
||||
$this->_contiguous = (bool)$contiguous;
|
||||
if (!$contiguous) {
|
||||
$this->_contiguousRow = -1;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // function setInputEncoding()
|
||||
|
||||
|
||||
/**
|
||||
* Get Contiguous
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function getContiguous() {
|
||||
return $this->_contiguous;
|
||||
} // function getSheetIndex()
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_DefaultReadFilter
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
/**
|
||||
* Should this cell be read?
|
||||
*
|
||||
* @param $column String column index
|
||||
* @param $row Row index
|
||||
* @param $worksheetName Optional worksheet name
|
||||
* @return boolean
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,804 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel2003XML
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_styles = array();
|
||||
|
||||
/**
|
||||
* Character set used in the file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_charSet = 'UTF-8';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Excel2003XML
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
|
||||
// Office xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
// Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
|
||||
// XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
|
||||
// Spreadsheet component xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
|
||||
// XML schema xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
|
||||
// XML data type xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
|
||||
// MS-persist recordset xmlns:rs="urn:schemas-microsoft-com:rowset"
|
||||
// Rowset xmlns:z="#RowsetSchema"
|
||||
//
|
||||
|
||||
$signature = array(
|
||||
'<?xml version="1.0"',
|
||||
'<?mso-application progid="Excel.Sheet"?>'
|
||||
);
|
||||
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Read sample data (first 2 KB will do)
|
||||
$fh = fopen($pFilename, 'r');
|
||||
$data = fread($fh, 2048);
|
||||
fclose($fh);
|
||||
|
||||
$valid = true;
|
||||
foreach($signature as $match) {
|
||||
// every part of the signature must be present
|
||||
if (strpos($data, $match) === false) {
|
||||
$valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve charset encoding
|
||||
if(preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um',$data,$matches)) {
|
||||
$this->_charSet = strtoupper($matches[1]);
|
||||
}
|
||||
// echo 'Character Set is ',$this->_charSet,'<br />';
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetNames($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
|
||||
$worksheetNames = array();
|
||||
|
||||
$xml = simplexml_load_file($pFilename);
|
||||
$namespaces = $xml->getNamespaces(true);
|
||||
|
||||
$xml_ss = $xml->children($namespaces['ss']);
|
||||
foreach($xml_ss->Worksheet as $worksheet) {
|
||||
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
|
||||
$worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet);
|
||||
}
|
||||
|
||||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$worksheetInfo = array();
|
||||
|
||||
$xml = simplexml_load_file($pFilename);
|
||||
$namespaces = $xml->getNamespaces(true);
|
||||
|
||||
$worksheetID = 1;
|
||||
$xml_ss = $xml->children($namespaces['ss']);
|
||||
foreach($xml_ss->Worksheet as $worksheet) {
|
||||
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
|
||||
|
||||
$tmpInfo = array();
|
||||
$tmpInfo['worksheetName'] = '';
|
||||
$tmpInfo['lastColumnLetter'] = 'A';
|
||||
$tmpInfo['lastColumnIndex'] = 0;
|
||||
$tmpInfo['totalRows'] = 0;
|
||||
$tmpInfo['totalColumns'] = 0;
|
||||
|
||||
if (isset($worksheet_ss['Name'])) {
|
||||
$tmpInfo['worksheetName'] = (string) $worksheet_ss['Name'];
|
||||
} else {
|
||||
$tmpInfo['worksheetName'] = "Worksheet_{$worksheetID}";
|
||||
}
|
||||
|
||||
if (isset($worksheet->Table->Row)) {
|
||||
$rowIndex = 0;
|
||||
|
||||
foreach($worksheet->Table->Row as $rowData) {
|
||||
$columnIndex = 0;
|
||||
$rowHasData = false;
|
||||
|
||||
foreach($rowData->Cell as $cell) {
|
||||
if (isset($cell->Data)) {
|
||||
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
|
||||
$rowHasData = true;
|
||||
}
|
||||
|
||||
++$columnIndex;
|
||||
}
|
||||
|
||||
++$rowIndex;
|
||||
|
||||
if ($rowHasData) {
|
||||
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
|
||||
$tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
|
||||
|
||||
$worksheetInfo[] = $tmpInfo;
|
||||
++$worksheetID;
|
||||
}
|
||||
|
||||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
|
||||
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
|
||||
$styleAttributeValue = strtolower($styleAttributeValue);
|
||||
foreach($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
$styleAttributeValue = $style;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pixel units to excel width units(units of 1/256th of a character width)
|
||||
* @param pxs
|
||||
* @return
|
||||
*/
|
||||
private static function _pixel2WidthUnits($pxs) {
|
||||
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
|
||||
|
||||
$widthUnits = 256 * ($pxs / 7);
|
||||
$widthUnits += $UNIT_OFFSET_MAP[($pxs % 7)];
|
||||
return $widthUnits;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* excel width units(units of 1/256th of a character width) to pixel units
|
||||
* @param widthUnits
|
||||
* @return
|
||||
*/
|
||||
private static function _widthUnits2Pixel($widthUnits) {
|
||||
$pixels = ($widthUnits / 256) * 7;
|
||||
$offsetWidthUnits = $widthUnits % 256;
|
||||
$pixels += round($offsetWidthUnits / (256 / 7));
|
||||
return $pixels;
|
||||
}
|
||||
|
||||
|
||||
private static function _hex2str($hex) {
|
||||
return chr(hexdec($hex[1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
|
||||
$underlineStyles = array (
|
||||
PHPExcel_Style_Font::UNDERLINE_NONE,
|
||||
PHPExcel_Style_Font::UNDERLINE_DOUBLE,
|
||||
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING,
|
||||
PHPExcel_Style_Font::UNDERLINE_SINGLE,
|
||||
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING
|
||||
);
|
||||
$verticalAlignmentStyles = array (
|
||||
PHPExcel_Style_Alignment::VERTICAL_BOTTOM,
|
||||
PHPExcel_Style_Alignment::VERTICAL_TOP,
|
||||
PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY
|
||||
);
|
||||
$horizontalAlignmentStyles = array (
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_GENERAL,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY
|
||||
);
|
||||
|
||||
$timezoneObj = new DateTimeZone('Europe/London');
|
||||
$GMT = new DateTimeZone('UTC');
|
||||
|
||||
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
if (!$this->canRead($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||
}
|
||||
|
||||
$xml = simplexml_load_file($pFilename);
|
||||
$namespaces = $xml->getNamespaces(true);
|
||||
|
||||
$docProps = $objPHPExcel->getProperties();
|
||||
if (isset($xml->DocumentProperties[0])) {
|
||||
foreach($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
|
||||
switch ($propertyName) {
|
||||
case 'Title' :
|
||||
$docProps->setTitle(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'Subject' :
|
||||
$docProps->setSubject(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'Author' :
|
||||
$docProps->setCreator(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'Created' :
|
||||
$creationDate = strtotime($propertyValue);
|
||||
$docProps->setCreated($creationDate);
|
||||
break;
|
||||
case 'LastAuthor' :
|
||||
$docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'LastSaved' :
|
||||
$lastSaveDate = strtotime($propertyValue);
|
||||
$docProps->setModified($lastSaveDate);
|
||||
break;
|
||||
case 'Company' :
|
||||
$docProps->setCompany(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'Category' :
|
||||
$docProps->setCategory(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'Manager' :
|
||||
$docProps->setManager(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'Keywords' :
|
||||
$docProps->setKeywords(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
case 'Description' :
|
||||
$docProps->setDescription(self::_convertStringEncoding($propertyValue,$this->_charSet));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($xml->CustomDocumentProperties)) {
|
||||
foreach($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
|
||||
$propertyAttributes = $propertyValue->attributes($namespaces['dt']);
|
||||
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str',$propertyName);
|
||||
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN;
|
||||
switch((string) $propertyAttributes) {
|
||||
case 'string' :
|
||||
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
|
||||
$propertyValue = trim($propertyValue);
|
||||
break;
|
||||
case 'boolean' :
|
||||
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
|
||||
$propertyValue = (bool) $propertyValue;
|
||||
break;
|
||||
case 'integer' :
|
||||
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER;
|
||||
$propertyValue = intval($propertyValue);
|
||||
break;
|
||||
case 'float' :
|
||||
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
|
||||
$propertyValue = floatval($propertyValue);
|
||||
break;
|
||||
case 'dateTime.tz' :
|
||||
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
|
||||
$propertyValue = strtotime(trim($propertyValue));
|
||||
break;
|
||||
}
|
||||
$docProps->setCustomProperty($propertyName,$propertyValue,$propertyType);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($xml->Styles[0] as $style) {
|
||||
$style_ss = $style->attributes($namespaces['ss']);
|
||||
$styleID = (string) $style_ss['ID'];
|
||||
// echo 'Style ID = '.$styleID.'<br />';
|
||||
if ($styleID == 'Default') {
|
||||
$this->_styles['Default'] = array();
|
||||
} else {
|
||||
$this->_styles[$styleID] = $this->_styles['Default'];
|
||||
}
|
||||
foreach ($style as $styleType => $styleData) {
|
||||
$styleAttributes = $styleData->attributes($namespaces['ss']);
|
||||
// echo $styleType.'<br />';
|
||||
switch ($styleType) {
|
||||
case 'Alignment' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
$styleAttributeValue = (string) $styleAttributeValue;
|
||||
switch ($styleAttributeKey) {
|
||||
case 'Vertical' :
|
||||
if (self::identifyFixedStyleValue($verticalAlignmentStyles,$styleAttributeValue)) {
|
||||
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
|
||||
}
|
||||
break;
|
||||
case 'Horizontal' :
|
||||
if (self::identifyFixedStyleValue($horizontalAlignmentStyles,$styleAttributeValue)) {
|
||||
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
|
||||
}
|
||||
break;
|
||||
case 'WrapText' :
|
||||
$this->_styles[$styleID]['alignment']['wrap'] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Borders' :
|
||||
foreach($styleData->Border as $borderStyle) {
|
||||
$borderAttributes = $borderStyle->attributes($namespaces['ss']);
|
||||
$thisBorder = array();
|
||||
foreach($borderAttributes as $borderStyleKey => $borderStyleValue) {
|
||||
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
|
||||
switch ($borderStyleKey) {
|
||||
case 'LineStyle' :
|
||||
$thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
|
||||
// $thisBorder['style'] = $borderStyleValue;
|
||||
break;
|
||||
case 'Weight' :
|
||||
// $thisBorder['style'] = $borderStyleValue;
|
||||
break;
|
||||
case 'Position' :
|
||||
$borderPosition = strtolower($borderStyleValue);
|
||||
break;
|
||||
case 'Color' :
|
||||
$borderColour = substr($borderStyleValue,1);
|
||||
$thisBorder['color']['rgb'] = $borderColour;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($thisBorder)) {
|
||||
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
|
||||
$this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Font' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
$styleAttributeValue = (string) $styleAttributeValue;
|
||||
switch ($styleAttributeKey) {
|
||||
case 'FontName' :
|
||||
$this->_styles[$styleID]['font']['name'] = $styleAttributeValue;
|
||||
break;
|
||||
case 'Size' :
|
||||
$this->_styles[$styleID]['font']['size'] = $styleAttributeValue;
|
||||
break;
|
||||
case 'Color' :
|
||||
$this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1);
|
||||
break;
|
||||
case 'Bold' :
|
||||
$this->_styles[$styleID]['font']['bold'] = true;
|
||||
break;
|
||||
case 'Italic' :
|
||||
$this->_styles[$styleID]['font']['italic'] = true;
|
||||
break;
|
||||
case 'Underline' :
|
||||
if (self::identifyFixedStyleValue($underlineStyles,$styleAttributeValue)) {
|
||||
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Interior' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
switch ($styleAttributeKey) {
|
||||
case 'Color' :
|
||||
$this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'NumberFormat' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
$styleAttributeValue = str_replace($fromFormats,$toFormats,$styleAttributeValue);
|
||||
switch ($styleAttributeValue) {
|
||||
case 'Short Date' :
|
||||
$styleAttributeValue = 'dd/mm/yyyy';
|
||||
break;
|
||||
}
|
||||
if ($styleAttributeValue > '') {
|
||||
$this->_styles[$styleID]['numberformat']['code'] = $styleAttributeValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Protection' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// print_r($this->_styles[$styleID]);
|
||||
// echo '<hr />';
|
||||
}
|
||||
// echo '<hr />';
|
||||
|
||||
$worksheetID = 0;
|
||||
$xml_ss = $xml->children($namespaces['ss']);
|
||||
|
||||
foreach($xml_ss->Worksheet as $worksheet) {
|
||||
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
|
||||
|
||||
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
|
||||
(!in_array($worksheet_ss['Name'], $this->_loadSheetsOnly))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// echo '<h3>Worksheet: ',$worksheet_ss['Name'],'<h3>';
|
||||
//
|
||||
// Create new Worksheet
|
||||
$objPHPExcel->createSheet();
|
||||
$objPHPExcel->setActiveSheetIndex($worksheetID);
|
||||
if (isset($worksheet_ss['Name'])) {
|
||||
$worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet);
|
||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
||||
// formula cells... during the load, all formulae should be correct, and we're simply bringing
|
||||
// the worksheet name in line with the formula, not the reverse
|
||||
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
|
||||
}
|
||||
|
||||
$columnID = 'A';
|
||||
if (isset($worksheet->Table->Column)) {
|
||||
foreach($worksheet->Table->Column as $columnData) {
|
||||
$columnData_ss = $columnData->attributes($namespaces['ss']);
|
||||
if (isset($columnData_ss['Index'])) {
|
||||
$columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1);
|
||||
}
|
||||
if (isset($columnData_ss['Width'])) {
|
||||
$columnWidth = $columnData_ss['Width'];
|
||||
// echo '<b>Setting column width for '.$columnID.' to '.$columnWidth.'</b><br />';
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setWidth($columnWidth / 5.4);
|
||||
}
|
||||
++$columnID;
|
||||
}
|
||||
}
|
||||
|
||||
$rowID = 1;
|
||||
if (isset($worksheet->Table->Row)) {
|
||||
foreach($worksheet->Table->Row as $rowData) {
|
||||
$rowHasData = false;
|
||||
$row_ss = $rowData->attributes($namespaces['ss']);
|
||||
if (isset($row_ss['Index'])) {
|
||||
$rowID = (integer) $row_ss['Index'];
|
||||
}
|
||||
// echo '<b>Row '.$rowID.'</b><br />';
|
||||
|
||||
$columnID = 'A';
|
||||
foreach($rowData->Cell as $cell) {
|
||||
|
||||
$cell_ss = $cell->attributes($namespaces['ss']);
|
||||
if (isset($cell_ss['Index'])) {
|
||||
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1);
|
||||
}
|
||||
$cellRange = $columnID.$rowID;
|
||||
|
||||
if ($this->getReadFilter() !== NULL) {
|
||||
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) {
|
||||
$columnTo = $columnID;
|
||||
if (isset($cell_ss['MergeAcross'])) {
|
||||
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] -1);
|
||||
}
|
||||
$rowTo = $rowID;
|
||||
if (isset($cell_ss['MergeDown'])) {
|
||||
$rowTo = $rowTo + $cell_ss['MergeDown'];
|
||||
}
|
||||
$cellRange .= ':'.$columnTo.$rowTo;
|
||||
$objPHPExcel->getActiveSheet()->mergeCells($cellRange);
|
||||
}
|
||||
|
||||
$cellIsSet = $hasCalculatedValue = false;
|
||||
$cellDataFormula = '';
|
||||
if (isset($cell_ss['Formula'])) {
|
||||
$cellDataFormula = $cell_ss['Formula'];
|
||||
// added this as a check for array formulas
|
||||
if (isset($cell_ss['ArrayRange'])) {
|
||||
$cellDataCSEFormula = $cell_ss['ArrayRange'];
|
||||
// echo "found an array formula at ".$columnID.$rowID."<br />";
|
||||
}
|
||||
$hasCalculatedValue = true;
|
||||
}
|
||||
if (isset($cell->Data)) {
|
||||
$cellValue = $cellData = $cell->Data;
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
$cellData_ss = $cellData->attributes($namespaces['ss']);
|
||||
if (isset($cellData_ss['Type'])) {
|
||||
$cellDataType = $cellData_ss['Type'];
|
||||
switch ($cellDataType) {
|
||||
/*
|
||||
const TYPE_STRING = 's';
|
||||
const TYPE_FORMULA = 'f';
|
||||
const TYPE_NUMERIC = 'n';
|
||||
const TYPE_BOOL = 'b';
|
||||
const TYPE_NULL = 'null';
|
||||
const TYPE_INLINE = 'inlineStr';
|
||||
const TYPE_ERROR = 'e';
|
||||
*/
|
||||
case 'String' :
|
||||
$cellValue = self::_convertStringEncoding($cellValue,$this->_charSet);
|
||||
$type = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
break;
|
||||
case 'Number' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$cellValue = (float) $cellValue;
|
||||
if (floor($cellValue) == $cellValue) {
|
||||
$cellValue = (integer) $cellValue;
|
||||
}
|
||||
break;
|
||||
case 'Boolean' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
$cellValue = ($cellValue != 0);
|
||||
break;
|
||||
case 'DateTime' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue));
|
||||
break;
|
||||
case 'Error' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasCalculatedValue) {
|
||||
// echo 'FORMULA<br />';
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
|
||||
if (substr($cellDataFormula,0,3) == 'of:') {
|
||||
$cellDataFormula = substr($cellDataFormula,3);
|
||||
// echo 'Before: ',$cellDataFormula,'<br />';
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
$key = false;
|
||||
foreach($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
$value = str_replace(array('[.','.',']'),'',$value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
// echo 'Before: ',$cellDataFormula,'<br />';
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
$key = false;
|
||||
foreach($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($key = !$key) {
|
||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach($cellReferences as $cellReference) {
|
||||
$rowReference = $cellReference[2][0];
|
||||
// Empty R reference is the current row
|
||||
if ($rowReference == '') $rowReference = $rowID;
|
||||
// Bracketed R references are relative to the current row
|
||||
if ($rowReference{0} == '[') $rowReference = $rowID + trim($rowReference,'[]');
|
||||
$columnReference = $cellReference[4][0];
|
||||
// Empty C reference is the current column
|
||||
if ($columnReference == '') $columnReference = $columnNumber;
|
||||
// Bracketed C references are relative to the current column
|
||||
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
|
||||
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
|
||||
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"',$temp);
|
||||
// echo 'After: ',$cellDataFormula,'<br />';
|
||||
}
|
||||
|
||||
// echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />';
|
||||
//
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue),$type);
|
||||
if ($hasCalculatedValue) {
|
||||
// echo 'Formula result is '.$cellValue.'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue);
|
||||
}
|
||||
$cellIsSet = $rowHasData = true;
|
||||
}
|
||||
|
||||
if (isset($cell->Comment)) {
|
||||
// echo '<b>comment found</b><br />';
|
||||
$commentAttributes = $cell->Comment->attributes($namespaces['ss']);
|
||||
$author = 'unknown';
|
||||
if (isset($commentAttributes->Author)) {
|
||||
$author = (string)$commentAttributes->Author;
|
||||
// echo 'Author: ',$author,'<br />';
|
||||
}
|
||||
$node = $cell->Comment->Data->asXML();
|
||||
// $annotation = str_replace('html:','',substr($node,49,-10));
|
||||
// echo $annotation,'<br />';
|
||||
$annotation = strip_tags($node);
|
||||
// echo 'Annotation: ',$annotation,'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
|
||||
->setAuthor(self::_convertStringEncoding($author ,$this->_charSet))
|
||||
->setText($this->_parseRichText($annotation) );
|
||||
}
|
||||
|
||||
if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
|
||||
$style = (string) $cell_ss['StyleID'];
|
||||
// echo 'Cell style for '.$columnID.$rowID.' is '.$style.'<br />';
|
||||
if ((isset($this->_styles[$style])) && (!empty($this->_styles[$style]))) {
|
||||
// echo 'Cell '.$columnID.$rowID.'<br />';
|
||||
// print_r($this->_styles[$style]);
|
||||
// echo '<br />';
|
||||
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL);
|
||||
}
|
||||
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
|
||||
}
|
||||
}
|
||||
++$columnID;
|
||||
}
|
||||
|
||||
if ($rowHasData) {
|
||||
if (isset($row_ss['StyleID'])) {
|
||||
$rowStyle = $row_ss['StyleID'];
|
||||
}
|
||||
if (isset($row_ss['Height'])) {
|
||||
$rowHeight = $row_ss['Height'];
|
||||
// echo '<b>Setting row height to '.$rowHeight.'</b><br />';
|
||||
$objPHPExcel->getActiveSheet()->getRowDimension($rowID)->setRowHeight($rowHeight);
|
||||
}
|
||||
}
|
||||
|
||||
++$rowID;
|
||||
}
|
||||
}
|
||||
++$worksheetID;
|
||||
}
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
|
||||
private static function _convertStringEncoding($string,$charset) {
|
||||
if ($charset != 'UTF-8') {
|
||||
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText(self::_convertStringEncoding($is,$this->_charSet));
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,517 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel2007_Chart
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel2007_Chart
|
||||
{
|
||||
private static function _getAttribute($component, $name, $format) {
|
||||
$attributes = $component->attributes();
|
||||
if (isset($attributes[$name])) {
|
||||
if ($format == 'string') {
|
||||
return (string) $attributes[$name];
|
||||
} elseif ($format == 'integer') {
|
||||
return (integer) $attributes[$name];
|
||||
} elseif ($format == 'boolean') {
|
||||
return (boolean) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true;
|
||||
} else {
|
||||
return (float) $attributes[$name];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} // function _getAttribute()
|
||||
|
||||
|
||||
private static function _readColor($color,$background=false) {
|
||||
if (isset($color["rgb"])) {
|
||||
return (string)$color["rgb"];
|
||||
} else if (isset($color["indexed"])) {
|
||||
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function readChart($chartElements,$chartName) {
|
||||
$namespacesChartMeta = $chartElements->getNamespaces(true);
|
||||
$chartElementsC = $chartElements->children($namespacesChartMeta['c']);
|
||||
|
||||
$XaxisLabel = $YaxisLabel = $legend = $title = NULL;
|
||||
$dispBlanksAs = $plotVisOnly = NULL;
|
||||
|
||||
foreach($chartElementsC as $chartElementKey => $chartElement) {
|
||||
switch ($chartElementKey) {
|
||||
case "chart":
|
||||
foreach($chartElement as $chartDetailsKey => $chartDetails) {
|
||||
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
|
||||
switch ($chartDetailsKey) {
|
||||
case "plotArea":
|
||||
$plotAreaLayout = $XaxisLable = $YaxisLable = null;
|
||||
$plotSeries = $plotAttributes = array();
|
||||
foreach($chartDetails as $chartDetailKey => $chartDetail) {
|
||||
switch ($chartDetailKey) {
|
||||
case "layout":
|
||||
$plotAreaLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'plotArea');
|
||||
break;
|
||||
case "catAx":
|
||||
if (isset($chartDetail->title)) {
|
||||
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
|
||||
}
|
||||
break;
|
||||
case "dateAx":
|
||||
if (isset($chartDetail->title)) {
|
||||
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
|
||||
}
|
||||
break;
|
||||
case "valAx":
|
||||
if (isset($chartDetail->title)) {
|
||||
$YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat');
|
||||
}
|
||||
break;
|
||||
case "barChart":
|
||||
case "bar3DChart":
|
||||
$barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
|
||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotSer->setPlotDirection($barDirection);
|
||||
$plotSeries[] = $plotSer;
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "lineChart":
|
||||
case "line3DChart":
|
||||
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "areaChart":
|
||||
case "area3DChart":
|
||||
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "doughnutChart":
|
||||
case "pieChart":
|
||||
case "pie3DChart":
|
||||
$explosion = isset($chartDetail->ser->explosion);
|
||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotSer->setPlotStyle($explosion);
|
||||
$plotSeries[] = $plotSer;
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "scatterChart":
|
||||
$scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
|
||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotSer->setPlotStyle($scatterStyle);
|
||||
$plotSeries[] = $plotSer;
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "bubbleChart":
|
||||
$bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
|
||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotSer->setPlotStyle($bubbleScale);
|
||||
$plotSeries[] = $plotSer;
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "radarChart":
|
||||
$radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
|
||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotSer->setPlotStyle($radarStyle);
|
||||
$plotSeries[] = $plotSer;
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "surfaceChart":
|
||||
case "surface3DChart":
|
||||
$wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
|
||||
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotSer->setPlotStyle($wireFrame);
|
||||
$plotSeries[] = $plotSer;
|
||||
$plotAttributes = self::_readChartAttributes($chartDetail);
|
||||
break;
|
||||
case "stockChart":
|
||||
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey);
|
||||
$plotAttributes = self::_readChartAttributes($plotAreaLayout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($plotAreaLayout == NULL) {
|
||||
$plotAreaLayout = new PHPExcel_Chart_Layout();
|
||||
}
|
||||
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries);
|
||||
self::_setChartAttributes($plotAreaLayout,$plotAttributes);
|
||||
break;
|
||||
case "plotVisOnly":
|
||||
$plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
|
||||
break;
|
||||
case "dispBlanksAs":
|
||||
$dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
|
||||
break;
|
||||
case "title":
|
||||
$title = self::_chartTitle($chartDetails,$namespacesChartMeta,'title');
|
||||
break;
|
||||
case "legend":
|
||||
$legendPos = 'r';
|
||||
$legendLayout = null;
|
||||
$legendOverlay = false;
|
||||
foreach($chartDetails as $chartDetailKey => $chartDetail) {
|
||||
switch ($chartDetailKey) {
|
||||
case "legendPos":
|
||||
$legendPos = self::_getAttribute($chartDetail, 'val', 'string');
|
||||
break;
|
||||
case "overlay":
|
||||
$legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
|
||||
break;
|
||||
case "layout":
|
||||
$legendLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'legend');
|
||||
break;
|
||||
}
|
||||
}
|
||||
$legend = new PHPExcel_Chart_Legend($legendPos, $legendLayout, $legendOverlay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel);
|
||||
|
||||
return $chart;
|
||||
} // function readChart()
|
||||
|
||||
|
||||
private static function _chartTitle($titleDetails,$namespacesChartMeta,$type) {
|
||||
$caption = array();
|
||||
$titleLayout = null;
|
||||
foreach($titleDetails as $titleDetailKey => $chartDetail) {
|
||||
switch ($titleDetailKey) {
|
||||
case "tx":
|
||||
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
|
||||
foreach($titleDetails as $titleKey => $titleDetail) {
|
||||
switch ($titleKey) {
|
||||
case "p":
|
||||
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
|
||||
$caption[] = self::_parseRichText($titleDetailPart);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "layout":
|
||||
$titleLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new PHPExcel_Chart_Title($caption, $titleLayout);
|
||||
} // function _chartTitle()
|
||||
|
||||
|
||||
private static function _chartLayoutDetails($chartDetail,$namespacesChartMeta) {
|
||||
if (!isset($chartDetail->manualLayout)) {
|
||||
return null;
|
||||
}
|
||||
$details = $chartDetail->manualLayout->children($namespacesChartMeta['c']);
|
||||
if (is_null($details)) {
|
||||
return null;
|
||||
}
|
||||
$layout = array();
|
||||
foreach($details as $detailKey => $detail) {
|
||||
// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL;
|
||||
$layout[$detailKey] = self::_getAttribute($detail, 'val', 'string');
|
||||
}
|
||||
return new PHPExcel_Chart_Layout($layout);
|
||||
} // function _chartLayoutDetails()
|
||||
|
||||
|
||||
private static function _chartDataSeries($chartDetail,$namespacesChartMeta,$plotType) {
|
||||
$multiSeriesType = NULL;
|
||||
$smoothLine = false;
|
||||
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
|
||||
|
||||
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
|
||||
foreach($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
|
||||
switch ($seriesDetailKey) {
|
||||
case "grouping":
|
||||
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
|
||||
break;
|
||||
case "ser":
|
||||
$marker = NULL;
|
||||
foreach($seriesDetails as $seriesKey => $seriesDetail) {
|
||||
switch ($seriesKey) {
|
||||
case "idx":
|
||||
$seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer');
|
||||
break;
|
||||
case "order":
|
||||
$seriesOrder = self::_getAttribute($seriesDetail, 'val', 'integer');
|
||||
$plotOrder[$seriesIndex] = $seriesOrder;
|
||||
break;
|
||||
case "tx":
|
||||
$seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
|
||||
break;
|
||||
case "marker":
|
||||
$marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string');
|
||||
break;
|
||||
case "smooth":
|
||||
$smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean');
|
||||
break;
|
||||
case "cat":
|
||||
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta);
|
||||
break;
|
||||
case "val":
|
||||
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
|
||||
break;
|
||||
case "xVal":
|
||||
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
|
||||
break;
|
||||
case "yVal":
|
||||
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine);
|
||||
} // function _chartDataSeries()
|
||||
|
||||
|
||||
private static function _chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker = null, $smoothLine = false) {
|
||||
if (isset($seriesDetail->strRef)) {
|
||||
$seriesSource = (string) $seriesDetail->strRef->f;
|
||||
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
|
||||
|
||||
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
||||
} elseif (isset($seriesDetail->numRef)) {
|
||||
$seriesSource = (string) $seriesDetail->numRef->f;
|
||||
$seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
|
||||
|
||||
return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
||||
} elseif (isset($seriesDetail->multiLvlStrRef)) {
|
||||
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
|
||||
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s');
|
||||
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
||||
|
||||
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
||||
} elseif (isset($seriesDetail->multiLvlNumRef)) {
|
||||
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
|
||||
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s');
|
||||
$seriesData['pointCount'] = count($seriesData['dataValues']);
|
||||
|
||||
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine);
|
||||
}
|
||||
return null;
|
||||
} // function _chartDataSeriesValueSet()
|
||||
|
||||
|
||||
private static function _chartDataSeriesValues($seriesValueSet,$dataType='n') {
|
||||
$seriesVal = array();
|
||||
$formatCode = '';
|
||||
$pointCount = 0;
|
||||
|
||||
foreach($seriesValueSet as $seriesValueIdx => $seriesValue) {
|
||||
switch ($seriesValueIdx) {
|
||||
case 'ptCount':
|
||||
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
|
||||
break;
|
||||
case 'formatCode':
|
||||
$formatCode = (string) $seriesValue;
|
||||
break;
|
||||
case 'pt':
|
||||
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
|
||||
if ($dataType == 's') {
|
||||
$seriesVal[$pointVal] = (string) $seriesValue->v;
|
||||
} else {
|
||||
$seriesVal[$pointVal] = (float) $seriesValue->v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($seriesVal)) {
|
||||
$seriesVal = NULL;
|
||||
}
|
||||
|
||||
return array( 'formatCode' => $formatCode,
|
||||
'pointCount' => $pointCount,
|
||||
'dataValues' => $seriesVal
|
||||
);
|
||||
} // function _chartDataSeriesValues()
|
||||
|
||||
|
||||
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet,$dataType='n') {
|
||||
$seriesVal = array();
|
||||
$formatCode = '';
|
||||
$pointCount = 0;
|
||||
|
||||
foreach($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
|
||||
foreach($seriesLevel as $seriesValueIdx => $seriesValue) {
|
||||
switch ($seriesValueIdx) {
|
||||
case 'ptCount':
|
||||
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
|
||||
break;
|
||||
case 'formatCode':
|
||||
$formatCode = (string) $seriesValue;
|
||||
break;
|
||||
case 'pt':
|
||||
$pointVal = self::_getAttribute($seriesValue, 'idx', 'integer');
|
||||
if ($dataType == 's') {
|
||||
$seriesVal[$pointVal][] = (string) $seriesValue->v;
|
||||
} else {
|
||||
$seriesVal[$pointVal][] = (float) $seriesValue->v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array( 'formatCode' => $formatCode,
|
||||
'pointCount' => $pointCount,
|
||||
'dataValues' => $seriesVal
|
||||
);
|
||||
} // function _chartDataSeriesValuesMultiLevel()
|
||||
|
||||
private static function _parseRichText($titleDetailPart = null) {
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
|
||||
if (isset($titleDetailElement->t)) {
|
||||
$objText = $value->createTextRun( (string) $titleDetailElement->t );
|
||||
}
|
||||
if (isset($titleDetailElement->rPr)) {
|
||||
if (isset($titleDetailElement->rPr->rFont["val"])) {
|
||||
$objText->getFont()->setName((string) $titleDetailElement->rPr->rFont["val"]);
|
||||
}
|
||||
|
||||
$fontSize = (self::_getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
|
||||
if (!is_null($fontSize)) {
|
||||
$objText->getFont()->setSize(floor($fontSize / 100));
|
||||
}
|
||||
|
||||
$fontColor = (self::_getAttribute($titleDetailElement->rPr, 'color', 'string'));
|
||||
if (!is_null($fontColor)) {
|
||||
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($fontColor) ) );
|
||||
}
|
||||
|
||||
$bold = self::_getAttribute($titleDetailElement->rPr, 'b', 'boolean');
|
||||
if (!is_null($bold)) {
|
||||
$objText->getFont()->setBold($bold);
|
||||
}
|
||||
|
||||
$italic = self::_getAttribute($titleDetailElement->rPr, 'i', 'boolean');
|
||||
if (!is_null($italic)) {
|
||||
$objText->getFont()->setItalic($italic);
|
||||
}
|
||||
|
||||
$baseline = self::_getAttribute($titleDetailElement->rPr, 'baseline', 'integer');
|
||||
if (!is_null($baseline)) {
|
||||
if ($baseline > 0) {
|
||||
$objText->getFont()->setSuperScript(true);
|
||||
} elseif($baseline < 0) {
|
||||
$objText->getFont()->setSubScript(true);
|
||||
}
|
||||
}
|
||||
|
||||
$underscore = (self::_getAttribute($titleDetailElement->rPr, 'u', 'string'));
|
||||
if (!is_null($underscore)) {
|
||||
if ($underscore == 'sng') {
|
||||
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
|
||||
} elseif($underscore == 'dbl') {
|
||||
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
|
||||
} else {
|
||||
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
$strikethrough = (self::_getAttribute($titleDetailElement->rPr, 's', 'string'));
|
||||
if (!is_null($strikethrough)) {
|
||||
if ($strikethrough == 'noStrike') {
|
||||
$objText->getFont()->setStrikethrough(false);
|
||||
} else {
|
||||
$objText->getFont()->setStrikethrough(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private static function _readChartAttributes($chartDetail) {
|
||||
$plotAttributes = array();
|
||||
if (isset($chartDetail->dLbls)) {
|
||||
if (isset($chartDetail->dLbls->howLegendKey)) {
|
||||
$plotAttributes['showLegendKey'] = self::_getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string');
|
||||
}
|
||||
if (isset($chartDetail->dLbls->showVal)) {
|
||||
$plotAttributes['showVal'] = self::_getAttribute($chartDetail->dLbls->showVal, 'val', 'string');
|
||||
}
|
||||
if (isset($chartDetail->dLbls->showCatName)) {
|
||||
$plotAttributes['showCatName'] = self::_getAttribute($chartDetail->dLbls->showCatName, 'val', 'string');
|
||||
}
|
||||
if (isset($chartDetail->dLbls->showSerName)) {
|
||||
$plotAttributes['showSerName'] = self::_getAttribute($chartDetail->dLbls->showSerName, 'val', 'string');
|
||||
}
|
||||
if (isset($chartDetail->dLbls->showPercent)) {
|
||||
$plotAttributes['showPercent'] = self::_getAttribute($chartDetail->dLbls->showPercent, 'val', 'string');
|
||||
}
|
||||
if (isset($chartDetail->dLbls->showBubbleSize)) {
|
||||
$plotAttributes['showBubbleSize'] = self::_getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string');
|
||||
}
|
||||
if (isset($chartDetail->dLbls->showLeaderLines)) {
|
||||
$plotAttributes['showLeaderLines'] = self::_getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string');
|
||||
}
|
||||
}
|
||||
|
||||
return $plotAttributes;
|
||||
}
|
||||
|
||||
private static function _setChartAttributes($plotArea,$plotAttributes)
|
||||
{
|
||||
foreach($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
|
||||
switch($plotAttributeKey) {
|
||||
case 'showLegendKey' :
|
||||
$plotArea->setShowLegendKey($plotAttributeValue);
|
||||
break;
|
||||
case 'showVal' :
|
||||
$plotArea->setShowVal($plotAttributeValue);
|
||||
break;
|
||||
case 'showCatName' :
|
||||
$plotArea->setShowCatName($plotAttributeValue);
|
||||
break;
|
||||
case 'showSerName' :
|
||||
$plotArea->setShowSerName($plotAttributeValue);
|
||||
break;
|
||||
case 'showPercent' :
|
||||
$plotArea->setShowPercent($plotAttributeValue);
|
||||
break;
|
||||
case 'showBubbleSize' :
|
||||
$plotArea->setShowBubbleSize($plotAttributeValue);
|
||||
break;
|
||||
case 'showLeaderLines' :
|
||||
$plotArea->setShowLeaderLines($plotAttributeValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel2007_Theme
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel2007_Theme
|
||||
{
|
||||
/**
|
||||
* Theme Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_themeName;
|
||||
|
||||
/**
|
||||
* Colour Scheme Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_colourSchemeName;
|
||||
|
||||
/**
|
||||
* Colour Map indexed by position
|
||||
*
|
||||
* @var array of string
|
||||
*/
|
||||
private $_colourMapValues;
|
||||
|
||||
|
||||
/**
|
||||
* Colour Map
|
||||
*
|
||||
* @var array of string
|
||||
*/
|
||||
private $_colourMap;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Theme
|
||||
*
|
||||
*/
|
||||
public function __construct($themeName,$colourSchemeName,$colourMap)
|
||||
{
|
||||
// Initialise values
|
||||
$this->_themeName = $themeName;
|
||||
$this->_colourSchemeName = $colourSchemeName;
|
||||
$this->_colourMap = $colourMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Theme Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getThemeName()
|
||||
{
|
||||
return $this->_themeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colour Scheme Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColourSchemeName() {
|
||||
return $this->_colourSchemeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get colour Map Value by Position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getColourByIndex($index=0) {
|
||||
if (isset($this->_colourMap[$index])) {
|
||||
return $this->_colourMap[$index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if ((is_object($value)) && ($key != '_parent')) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,640 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_Escher
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
const DGGCONTAINER = 0xF000;
|
||||
const BSTORECONTAINER = 0xF001;
|
||||
const DGCONTAINER = 0xF002;
|
||||
const SPGRCONTAINER = 0xF003;
|
||||
const SPCONTAINER = 0xF004;
|
||||
const DGG = 0xF006;
|
||||
const BSE = 0xF007;
|
||||
const DG = 0xF008;
|
||||
const SPGR = 0xF009;
|
||||
const SP = 0xF00A;
|
||||
const OPT = 0xF00B;
|
||||
const CLIENTTEXTBOX = 0xF00D;
|
||||
const CLIENTANCHOR = 0xF010;
|
||||
const CLIENTDATA = 0xF011;
|
||||
const BLIPJPEG = 0xF01D;
|
||||
const BLIPPNG = 0xF01E;
|
||||
const SPLITMENUCOLORS = 0xF11E;
|
||||
const TERTIARYOPT = 0xF122;
|
||||
|
||||
/**
|
||||
* Escher stream data (binary)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* Size in bytes of the Escher stream data
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_dataSize;
|
||||
|
||||
/**
|
||||
* Current position of stream pointer in Escher stream data
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_pos;
|
||||
|
||||
/**
|
||||
* The object to be returned by the reader. Modified during load.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_object;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Excel5_Escher instance
|
||||
*
|
||||
* @param mixed $object
|
||||
*/
|
||||
public function __construct($object)
|
||||
{
|
||||
$this->_object = $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Escher stream data. May be a partial Escher stream.
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function load($data)
|
||||
{
|
||||
$this->_data = $data;
|
||||
|
||||
// total byte size of Excel data (workbook global substream + sheet substreams)
|
||||
$this->_dataSize = strlen($this->_data);
|
||||
|
||||
$this->_pos = 0;
|
||||
|
||||
// Parse Escher stream
|
||||
while ($this->_pos < $this->_dataSize) {
|
||||
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
|
||||
|
||||
switch ($fbt) {
|
||||
case self::DGGCONTAINER: $this->_readDggContainer(); break;
|
||||
case self::DGG: $this->_readDgg(); break;
|
||||
case self::BSTORECONTAINER: $this->_readBstoreContainer(); break;
|
||||
case self::BSE: $this->_readBSE(); break;
|
||||
case self::BLIPJPEG: $this->_readBlipJPEG(); break;
|
||||
case self::BLIPPNG: $this->_readBlipPNG(); break;
|
||||
case self::OPT: $this->_readOPT(); break;
|
||||
case self::TERTIARYOPT: $this->_readTertiaryOPT(); break;
|
||||
case self::SPLITMENUCOLORS: $this->_readSplitMenuColors(); break;
|
||||
case self::DGCONTAINER: $this->_readDgContainer(); break;
|
||||
case self::DG: $this->_readDg(); break;
|
||||
case self::SPGRCONTAINER: $this->_readSpgrContainer(); break;
|
||||
case self::SPCONTAINER: $this->_readSpContainer(); break;
|
||||
case self::SPGR: $this->_readSpgr(); break;
|
||||
case self::SP: $this->_readSp(); break;
|
||||
case self::CLIENTTEXTBOX: $this->_readClientTextbox(); break;
|
||||
case self::CLIENTANCHOR: $this->_readClientAnchor(); break;
|
||||
case self::CLIENTDATA: $this->_readClientData(); break;
|
||||
default: $this->_readDefault(); break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a generic record
|
||||
*/
|
||||
private function _readDefault()
|
||||
{
|
||||
// offset 0; size: 2; recVer and recInstance
|
||||
$verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos);
|
||||
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
|
||||
|
||||
// bit: 0-3; mask: 0x000F; recVer
|
||||
$recVer = (0x000F & $verInstance) >> 0;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read DggContainer record (Drawing Group Container)
|
||||
*/
|
||||
private function _readDggContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
|
||||
$this->_object->setDggContainer($dggContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($dggContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Dgg record (Drawing Group)
|
||||
*/
|
||||
private function _readDgg()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BstoreContainer record (Blip Store Container)
|
||||
*/
|
||||
private function _readBstoreContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
|
||||
$this->_object->setBstoreContainer($bstoreContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BSE record
|
||||
*/
|
||||
private function _readBSE()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
// add BSE to BstoreContainer
|
||||
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
|
||||
$this->_object->addBSE($BSE);
|
||||
|
||||
$BSE->setBLIPType($recInstance);
|
||||
|
||||
// offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
|
||||
$btWin32 = ord($recordData[0]);
|
||||
|
||||
// offset: 1; size: 1; btWin32 (MSOBLIPTYPE)
|
||||
$btMacOS = ord($recordData[1]);
|
||||
|
||||
// offset: 2; size: 16; MD4 digest
|
||||
$rgbUid = substr($recordData, 2, 16);
|
||||
|
||||
// offset: 18; size: 2; tag
|
||||
$tag = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 18);
|
||||
|
||||
// offset: 20; size: 4; size of BLIP in bytes
|
||||
$size = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 20);
|
||||
|
||||
// offset: 24; size: 4; number of references to this BLIP
|
||||
$cRef = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 24);
|
||||
|
||||
// offset: 28; size: 4; MSOFO file offset
|
||||
$foDelay = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 28);
|
||||
|
||||
// offset: 32; size: 1; unused1
|
||||
$unused1 = ord($recordData{32});
|
||||
|
||||
// offset: 33; size: 1; size of nameData in bytes (including null terminator)
|
||||
$cbName = ord($recordData{33});
|
||||
|
||||
// offset: 34; size: 1; unused2
|
||||
$unused2 = ord($recordData{34});
|
||||
|
||||
// offset: 35; size: 1; unused3
|
||||
$unused3 = ord($recordData{35});
|
||||
|
||||
// offset: 36; size: $cbName; nameData
|
||||
$nameData = substr($recordData, 36, $cbName);
|
||||
|
||||
// offset: 36 + $cbName, size: var; the BLIP data
|
||||
$blipData = substr($recordData, 36 + $cbName);
|
||||
|
||||
// record is a container, read contents
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($BSE);
|
||||
$reader->load($blipData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BlipJPEG record. Holds raw JPEG image data
|
||||
*/
|
||||
private function _readBlipJPEG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
$pos = 0;
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if (in_array($recInstance, array(0x046B, 0x06E3))) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData{$pos});
|
||||
$pos += 1;
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
$this->_object->setBlip($blip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BlipPNG record. Holds raw PNG image data
|
||||
*/
|
||||
private function _readBlipPNG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
$pos = 0;
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if ($recInstance == 0x06E1) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData{$pos});
|
||||
$pos += 1;
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
$this->_object->setBlip($blip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read OPT record. This record may occur within DggContainer record or SpContainer
|
||||
*/
|
||||
private function _readOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
$this->_readOfficeArtRGFOPTE($recordData, $recInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read TertiaryOPT record
|
||||
*/
|
||||
private function _readTertiaryOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SplitMenuColors record
|
||||
*/
|
||||
private function _readSplitMenuColors()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read DgContainer record (Drawing Container)
|
||||
*/
|
||||
private function _readDgContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
|
||||
$this->_object->setDgContainer($dgContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($dgContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Dg record (Drawing)
|
||||
*/
|
||||
private function _readDg()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SpgrContainer record (Shape Group Container)
|
||||
*/
|
||||
private function _readSpgrContainer()
|
||||
{
|
||||
// context is either context DgContainer or SpgrContainer
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
|
||||
|
||||
if ($this->_object instanceof PHPExcel_Shared_Escher_DgContainer) {
|
||||
// DgContainer
|
||||
$this->_object->setSpgrContainer($spgrContainer);
|
||||
} else {
|
||||
// SpgrContainer
|
||||
$this->_object->addChild($spgrContainer);
|
||||
}
|
||||
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SpContainer record (Shape Container)
|
||||
*/
|
||||
private function _readSpContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// add spContainer to spgrContainer
|
||||
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
|
||||
$this->_object->addChild($spContainer);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($spContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Spgr record (Shape Group)
|
||||
*/
|
||||
private function _readSpgr()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Sp record (Shape)
|
||||
*/
|
||||
private function _readSp()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientTextbox record
|
||||
*/
|
||||
private function _readClientTextbox()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet
|
||||
*/
|
||||
private function _readClientAnchor()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
// offset: 2; size: 2; upper-left corner column index (0-based)
|
||||
$c1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 2);
|
||||
|
||||
// offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
|
||||
$startOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 4);
|
||||
|
||||
// offset: 6; size: 2; upper-left corner row index (0-based)
|
||||
$r1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 6);
|
||||
|
||||
// offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
|
||||
$startOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 8);
|
||||
|
||||
// offset: 10; size: 2; bottom-right corner column index (0-based)
|
||||
$c2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 10);
|
||||
|
||||
// offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
|
||||
$endOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 12);
|
||||
|
||||
// offset: 14; size: 2; bottom-right corner row index (0-based)
|
||||
$r2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 14);
|
||||
|
||||
// offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
|
||||
$endOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 16);
|
||||
|
||||
// set the start coordinates
|
||||
$this->_object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
|
||||
|
||||
// set the start offsetX
|
||||
$this->_object->setStartOffsetX($startOffsetX);
|
||||
|
||||
// set the start offsetY
|
||||
$this->_object->setStartOffsetY($startOffsetY);
|
||||
|
||||
// set the end coordinates
|
||||
$this->_object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1));
|
||||
|
||||
// set the end offsetX
|
||||
$this->_object->setEndOffsetX($endOffsetX);
|
||||
|
||||
// set the end offsetY
|
||||
$this->_object->setEndOffsetY($endOffsetY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientData record
|
||||
*/
|
||||
private function _readClientData()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read OfficeArtRGFOPTE table of property-value pairs
|
||||
*
|
||||
* @param string $data Binary data
|
||||
* @param int $n Number of properties
|
||||
*/
|
||||
private function _readOfficeArtRGFOPTE($data, $n) {
|
||||
|
||||
$splicedComplexData = substr($data, 6 * $n);
|
||||
|
||||
// loop through property-value pairs
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
// read 6 bytes at a time
|
||||
$fopte = substr($data, 6 * $i, 6);
|
||||
|
||||
// offset: 0; size: 2; opid
|
||||
$opid = PHPExcel_Reader_Excel5::_GetInt2d($fopte, 0);
|
||||
|
||||
// bit: 0-13; mask: 0x3FFF; opid.opid
|
||||
$opidOpid = (0x3FFF & $opid) >> 0;
|
||||
|
||||
// bit: 14; mask 0x4000; 1 = value in op field is BLIP identifier
|
||||
$opidFBid = (0x4000 & $opid) >> 14;
|
||||
|
||||
// bit: 15; mask 0x8000; 1 = this is a complex property, op field specifies size of complex data
|
||||
$opidFComplex = (0x8000 & $opid) >> 15;
|
||||
|
||||
// offset: 2; size: 4; the value for this property
|
||||
$op = PHPExcel_Reader_Excel5::_GetInt4d($fopte, 2);
|
||||
|
||||
if ($opidFComplex) {
|
||||
$complexData = substr($splicedComplexData, 0, $op);
|
||||
$splicedComplexData = substr($splicedComplexData, $op);
|
||||
|
||||
// we store string value with complex data
|
||||
$value = $complexData;
|
||||
} else {
|
||||
// we store integer value
|
||||
$value = $op;
|
||||
}
|
||||
|
||||
$this->_object->setOPT($opidOpid, $value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Exception extends Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,866 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Gnumeric
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_styles = array();
|
||||
|
||||
/**
|
||||
* Shared Expressions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_expressions = array();
|
||||
|
||||
private $_referenceHelper = null;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Gnumeric
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Check if gzlib functions are available
|
||||
if (!function_exists('gzread')) {
|
||||
throw new PHPExcel_Reader_Exception("gzlib library is not enabled");
|
||||
}
|
||||
|
||||
// Read signature data (first 3 bytes)
|
||||
$fh = fopen($pFilename, 'r');
|
||||
$data = fread($fh, 2);
|
||||
fclose($fh);
|
||||
|
||||
if ($data != chr(0x1F).chr(0x8B)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$gFileData = $this->_gzfileGetContents($pFilename);
|
||||
|
||||
$xml = simplexml_load_string($gFileData);
|
||||
$namespacesMeta = $xml->getNamespaces(true);
|
||||
|
||||
$gnmXML = $xml->children($namespacesMeta['gnm']);
|
||||
|
||||
$worksheetInfo = array();
|
||||
|
||||
foreach ($gnmXML->Sheets->Sheet as $sheet) {
|
||||
$tmpInfo = array();
|
||||
$tmpInfo['worksheetName'] = (string) $sheet->Name;
|
||||
$tmpInfo['lastColumnLetter'] = 'A';
|
||||
$tmpInfo['lastColumnIndex'] = 0;
|
||||
$tmpInfo['totalRows'] = 0;
|
||||
$tmpInfo['totalColumns'] = 0;
|
||||
|
||||
foreach ($sheet->Cells->Cell as $cell) {
|
||||
$cellAttributes = $cell->attributes();
|
||||
|
||||
$rowIndex = (int) $cellAttributes->Row + 1;
|
||||
$columnIndex = (int) $cellAttributes->Col;
|
||||
|
||||
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
|
||||
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
|
||||
}
|
||||
|
||||
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
|
||||
$tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
|
||||
|
||||
$worksheetInfo[] = $tmpInfo;
|
||||
}
|
||||
|
||||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
private function _gzfileGetContents($filename) {
|
||||
$file = @gzopen($filename, 'rb');
|
||||
if ($file !== false) {
|
||||
$data = '';
|
||||
while (!gzeof($file)) {
|
||||
$data .= gzread($file, 1024);
|
||||
}
|
||||
gzclose($file);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetNames($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$gFileData = $this->_gzfileGetContents($pFilename);
|
||||
|
||||
$xml = simplexml_load_string($gFileData);
|
||||
$namespacesMeta = $xml->getNamespaces(true);
|
||||
|
||||
$gnmXML = $xml->children($namespacesMeta['gnm']);
|
||||
|
||||
$worksheetNames = array();
|
||||
|
||||
foreach($gnmXML->Sheets->Sheet as $sheet) {
|
||||
$worksheetNames[] = (string) $sheet->Name;
|
||||
}
|
||||
|
||||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$timezoneObj = new DateTimeZone('Europe/London');
|
||||
$GMT = new DateTimeZone('UTC');
|
||||
|
||||
$gFileData = $this->_gzfileGetContents($pFilename);
|
||||
|
||||
// echo '<pre>';
|
||||
// echo htmlentities($gFileData,ENT_QUOTES,'UTF-8');
|
||||
// echo '</pre><hr />';
|
||||
//
|
||||
$xml = simplexml_load_string($gFileData);
|
||||
$namespacesMeta = $xml->getNamespaces(true);
|
||||
|
||||
// var_dump($namespacesMeta);
|
||||
//
|
||||
$gnmXML = $xml->children($namespacesMeta['gnm']);
|
||||
|
||||
$docProps = $objPHPExcel->getProperties();
|
||||
// Document Properties are held differently, depending on the version of Gnumeric
|
||||
if (isset($namespacesMeta['office'])) {
|
||||
$officeXML = $xml->children($namespacesMeta['office']);
|
||||
$officeDocXML = $officeXML->{'document-meta'};
|
||||
$officeDocMetaXML = $officeDocXML->meta;
|
||||
|
||||
foreach($officeDocMetaXML as $officePropertyData) {
|
||||
|
||||
$officePropertyDC = array();
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
|
||||
}
|
||||
foreach($officePropertyDC as $propertyName => $propertyValue) {
|
||||
$propertyValue = (string) $propertyValue;
|
||||
switch ($propertyName) {
|
||||
case 'title' :
|
||||
$docProps->setTitle(trim($propertyValue));
|
||||
break;
|
||||
case 'subject' :
|
||||
$docProps->setSubject(trim($propertyValue));
|
||||
break;
|
||||
case 'creator' :
|
||||
$docProps->setCreator(trim($propertyValue));
|
||||
$docProps->setLastModifiedBy(trim($propertyValue));
|
||||
break;
|
||||
case 'date' :
|
||||
$creationDate = strtotime(trim($propertyValue));
|
||||
$docProps->setCreated($creationDate);
|
||||
$docProps->setModified($creationDate);
|
||||
break;
|
||||
case 'description' :
|
||||
$docProps->setDescription(trim($propertyValue));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$officePropertyMeta = array();
|
||||
if (isset($namespacesMeta['meta'])) {
|
||||
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
|
||||
}
|
||||
foreach($officePropertyMeta as $propertyName => $propertyValue) {
|
||||
$attributes = $propertyValue->attributes($namespacesMeta['meta']);
|
||||
$propertyValue = (string) $propertyValue;
|
||||
switch ($propertyName) {
|
||||
case 'keyword' :
|
||||
$docProps->setKeywords(trim($propertyValue));
|
||||
break;
|
||||
case 'initial-creator' :
|
||||
$docProps->setCreator(trim($propertyValue));
|
||||
$docProps->setLastModifiedBy(trim($propertyValue));
|
||||
break;
|
||||
case 'creation-date' :
|
||||
$creationDate = strtotime(trim($propertyValue));
|
||||
$docProps->setCreated($creationDate);
|
||||
$docProps->setModified($creationDate);
|
||||
break;
|
||||
case 'user-defined' :
|
||||
list(,$attrName) = explode(':',$attributes['name']);
|
||||
switch ($attrName) {
|
||||
case 'publisher' :
|
||||
$docProps->setCompany(trim($propertyValue));
|
||||
break;
|
||||
case 'category' :
|
||||
$docProps->setCategory(trim($propertyValue));
|
||||
break;
|
||||
case 'manager' :
|
||||
$docProps->setManager(trim($propertyValue));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (isset($gnmXML->Summary)) {
|
||||
foreach($gnmXML->Summary->Item as $summaryItem) {
|
||||
$propertyName = $summaryItem->name;
|
||||
$propertyValue = $summaryItem->{'val-string'};
|
||||
switch ($propertyName) {
|
||||
case 'title' :
|
||||
$docProps->setTitle(trim($propertyValue));
|
||||
break;
|
||||
case 'comments' :
|
||||
$docProps->setDescription(trim($propertyValue));
|
||||
break;
|
||||
case 'keywords' :
|
||||
$docProps->setKeywords(trim($propertyValue));
|
||||
break;
|
||||
case 'category' :
|
||||
$docProps->setCategory(trim($propertyValue));
|
||||
break;
|
||||
case 'manager' :
|
||||
$docProps->setManager(trim($propertyValue));
|
||||
break;
|
||||
case 'author' :
|
||||
$docProps->setCreator(trim($propertyValue));
|
||||
$docProps->setLastModifiedBy(trim($propertyValue));
|
||||
break;
|
||||
case 'company' :
|
||||
$docProps->setCompany(trim($propertyValue));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$worksheetID = 0;
|
||||
foreach($gnmXML->Sheets->Sheet as $sheet) {
|
||||
$worksheetName = (string) $sheet->Name;
|
||||
// echo '<b>Worksheet: ',$worksheetName,'</b><br />';
|
||||
if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$maxRow = $maxCol = 0;
|
||||
|
||||
// Create new Worksheet
|
||||
$objPHPExcel->createSheet();
|
||||
$objPHPExcel->setActiveSheetIndex($worksheetID);
|
||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
|
||||
// cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
|
||||
// name in line with the formula, not the reverse
|
||||
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
|
||||
|
||||
if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) {
|
||||
if (isset($sheet->PrintInformation->Margins)) {
|
||||
foreach($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) {
|
||||
$marginAttributes = $margin->attributes();
|
||||
$marginSize = 72 / 100; // Default
|
||||
switch($marginAttributes['PrefUnit']) {
|
||||
case 'mm' :
|
||||
$marginSize = intval($marginAttributes['Points']) / 100;
|
||||
break;
|
||||
}
|
||||
switch($key) {
|
||||
case 'top' :
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize);
|
||||
break;
|
||||
case 'bottom' :
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize);
|
||||
break;
|
||||
case 'left' :
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize);
|
||||
break;
|
||||
case 'right' :
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize);
|
||||
break;
|
||||
case 'header' :
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize);
|
||||
break;
|
||||
case 'footer' :
|
||||
$objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($sheet->Cells->Cell as $cell) {
|
||||
$cellAttributes = $cell->attributes();
|
||||
$row = (int) $cellAttributes->Row + 1;
|
||||
$column = (int) $cellAttributes->Col;
|
||||
|
||||
if ($row > $maxRow) $maxRow = $row;
|
||||
if ($column > $maxCol) $maxCol = $column;
|
||||
|
||||
$column = PHPExcel_Cell::stringFromColumnIndex($column);
|
||||
|
||||
// Read cell?
|
||||
if ($this->getReadFilter() !== NULL) {
|
||||
if (!$this->getReadFilter()->readCell($column, $row, $worksheetName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$ValueType = $cellAttributes->ValueType;
|
||||
$ExprID = (string) $cellAttributes->ExprID;
|
||||
// echo 'Cell ',$column,$row,'<br />';
|
||||
// echo 'Type is ',$ValueType,'<br />';
|
||||
// echo 'Value is ',$cell,'<br />';
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
if ($ExprID > '') {
|
||||
if (((string) $cell) > '') {
|
||||
|
||||
$this->_expressions[$ExprID] = array( 'column' => $cellAttributes->Col,
|
||||
'row' => $cellAttributes->Row,
|
||||
'formula' => (string) $cell
|
||||
);
|
||||
// echo 'NEW EXPRESSION ',$ExprID,'<br />';
|
||||
} else {
|
||||
$expression = $this->_expressions[$ExprID];
|
||||
|
||||
$cell = $this->_referenceHelper->updateFormulaReferences( $expression['formula'],
|
||||
'A1',
|
||||
$cellAttributes->Col - $expression['column'],
|
||||
$cellAttributes->Row - $expression['row'],
|
||||
$worksheetName
|
||||
);
|
||||
// echo 'SHARED EXPRESSION ',$ExprID,'<br />';
|
||||
// echo 'New Value is ',$cell,'<br />';
|
||||
}
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
} else {
|
||||
switch($ValueType) {
|
||||
case '10' : // NULL
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
break;
|
||||
case '20' : // Boolean
|
||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
$cell = ($cell == 'TRUE') ? True : False;
|
||||
break;
|
||||
case '30' : // Integer
|
||||
$cell = intval($cell);
|
||||
case '40' : // Float
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
break;
|
||||
case '50' : // Error
|
||||
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
break;
|
||||
case '60' : // String
|
||||
$type = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
break;
|
||||
case '70' : // Cell Range
|
||||
case '80' : // Array
|
||||
}
|
||||
}
|
||||
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell,$type);
|
||||
}
|
||||
|
||||
if ((!$this->_readDataOnly) && (isset($sheet->Objects))) {
|
||||
foreach($sheet->Objects->children('gnm',TRUE) as $key => $comment) {
|
||||
$commentAttributes = $comment->attributes();
|
||||
// Only comment objects are handled at the moment
|
||||
if ($commentAttributes->Text) {
|
||||
$objPHPExcel->getActiveSheet()->getComment( (string)$commentAttributes->ObjectBound )
|
||||
->setAuthor( (string)$commentAttributes->Author )
|
||||
->setText($this->_parseRichText((string)$commentAttributes->Text) );
|
||||
}
|
||||
}
|
||||
}
|
||||
// echo '$maxCol=',$maxCol,'; $maxRow=',$maxRow,'<br />';
|
||||
//
|
||||
foreach($sheet->Styles->StyleRegion as $styleRegion) {
|
||||
$styleAttributes = $styleRegion->attributes();
|
||||
if (($styleAttributes['startRow'] <= $maxRow) &&
|
||||
($styleAttributes['startCol'] <= $maxCol)) {
|
||||
|
||||
$startColumn = PHPExcel_Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
|
||||
$startRow = $styleAttributes['startRow'] + 1;
|
||||
|
||||
$endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol'];
|
||||
$endColumn = PHPExcel_Cell::stringFromColumnIndex($endColumn);
|
||||
$endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow'];
|
||||
$endRow += 1;
|
||||
$cellRange = $startColumn.$startRow.':'.$endColumn.$endRow;
|
||||
// echo $cellRange,'<br />';
|
||||
|
||||
$styleAttributes = $styleRegion->Style->attributes();
|
||||
// var_dump($styleAttributes);
|
||||
// echo '<br />';
|
||||
|
||||
// We still set the number format mask for date/time values, even if _readDataOnly is true
|
||||
if ((!$this->_readDataOnly) ||
|
||||
(PHPExcel_Shared_Date::isDateTimeFormatCode($styleArray['numberformat']['code']))) {
|
||||
$styleArray = array();
|
||||
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
|
||||
// If _readDataOnly is false, we set all formatting information
|
||||
if (!$this->_readDataOnly) {
|
||||
switch($styleAttributes['HAlign']) {
|
||||
case '1' :
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
break;
|
||||
case '2' :
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
|
||||
break;
|
||||
case '4' :
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
|
||||
break;
|
||||
case '8' :
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
|
||||
break;
|
||||
case '16' :
|
||||
case '64' :
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS;
|
||||
break;
|
||||
case '32' :
|
||||
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY;
|
||||
break;
|
||||
}
|
||||
|
||||
switch($styleAttributes['VAlign']) {
|
||||
case '1' :
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
|
||||
break;
|
||||
case '2' :
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
break;
|
||||
case '4' :
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER;
|
||||
break;
|
||||
case '8' :
|
||||
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY;
|
||||
break;
|
||||
}
|
||||
|
||||
$styleArray['alignment']['wrap'] = ($styleAttributes['WrapText'] == '1') ? True : False;
|
||||
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? True : False;
|
||||
$styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0;
|
||||
|
||||
$RGB = self::_parseGnumericColour($styleAttributes["Fore"]);
|
||||
$styleArray['font']['color']['rgb'] = $RGB;
|
||||
$RGB = self::_parseGnumericColour($styleAttributes["Back"]);
|
||||
$shade = $styleAttributes["Shade"];
|
||||
if (($RGB != '000000') || ($shade != '0')) {
|
||||
$styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB;
|
||||
$RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]);
|
||||
$styleArray['fill']['endcolor']['rgb'] = $RGB2;
|
||||
switch($shade) {
|
||||
case '1' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
|
||||
break;
|
||||
case '2' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR;
|
||||
break;
|
||||
case '3' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH;
|
||||
break;
|
||||
case '4' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN;
|
||||
break;
|
||||
case '5' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY;
|
||||
break;
|
||||
case '6' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID;
|
||||
break;
|
||||
case '7' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
|
||||
break;
|
||||
case '8' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS;
|
||||
break;
|
||||
case '9' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP;
|
||||
break;
|
||||
case '10' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL;
|
||||
break;
|
||||
case '11' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625;
|
||||
break;
|
||||
case '12' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125;
|
||||
break;
|
||||
case '13' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN;
|
||||
break;
|
||||
case '14' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY;
|
||||
break;
|
||||
case '15' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID;
|
||||
break;
|
||||
case '16' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
|
||||
break;
|
||||
case '17' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
|
||||
break;
|
||||
case '18' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP;
|
||||
break;
|
||||
case '19' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
|
||||
break;
|
||||
case '20' :
|
||||
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$fontAttributes = $styleRegion->Style->Font->attributes();
|
||||
// var_dump($fontAttributes);
|
||||
// echo '<br />';
|
||||
$styleArray['font']['name'] = (string) $styleRegion->Style->Font;
|
||||
$styleArray['font']['size'] = intval($fontAttributes['Unit']);
|
||||
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False;
|
||||
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False;
|
||||
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False;
|
||||
switch($fontAttributes['Underline']) {
|
||||
case '1' :
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
|
||||
break;
|
||||
case '2' :
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE;
|
||||
break;
|
||||
case '3' :
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING;
|
||||
break;
|
||||
case '4' :
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING;
|
||||
break;
|
||||
default :
|
||||
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
|
||||
break;
|
||||
}
|
||||
switch($fontAttributes['Script']) {
|
||||
case '1' :
|
||||
$styleArray['font']['superScript'] = True;
|
||||
break;
|
||||
case '-1' :
|
||||
$styleArray['font']['subScript'] = True;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($styleRegion->Style->StyleBorder)) {
|
||||
if (isset($styleRegion->Style->StyleBorder->Top)) {
|
||||
$styleArray['borders']['top'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Top->attributes());
|
||||
}
|
||||
if (isset($styleRegion->Style->StyleBorder->Bottom)) {
|
||||
$styleArray['borders']['bottom'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Bottom->attributes());
|
||||
}
|
||||
if (isset($styleRegion->Style->StyleBorder->Left)) {
|
||||
$styleArray['borders']['left'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Left->attributes());
|
||||
}
|
||||
if (isset($styleRegion->Style->StyleBorder->Right)) {
|
||||
$styleArray['borders']['right'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Right->attributes());
|
||||
}
|
||||
if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) {
|
||||
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
|
||||
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_BOTH;
|
||||
} elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) {
|
||||
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
|
||||
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_UP;
|
||||
} elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) {
|
||||
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes());
|
||||
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_DOWN;
|
||||
}
|
||||
}
|
||||
if (isset($styleRegion->Style->HyperLink)) {
|
||||
// TO DO
|
||||
$hyperlink = $styleRegion->Style->HyperLink->attributes();
|
||||
}
|
||||
}
|
||||
// var_dump($styleArray);
|
||||
// echo '<br />';
|
||||
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($styleArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((!$this->_readDataOnly) && (isset($sheet->Cols))) {
|
||||
// Column Widths
|
||||
$columnAttributes = $sheet->Cols->attributes();
|
||||
$defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4;
|
||||
$c = 0;
|
||||
foreach($sheet->Cols->ColInfo as $columnOverride) {
|
||||
$columnAttributes = $columnOverride->attributes();
|
||||
$column = $columnAttributes['No'];
|
||||
$columnWidth = $columnAttributes['Unit'] / 5.4;
|
||||
$hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false;
|
||||
$columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1;
|
||||
while ($c < $column) {
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
|
||||
++$c;
|
||||
}
|
||||
while (($c < ($column+$columnCount)) && ($c <= $maxCol)) {
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($columnWidth);
|
||||
if ($hidden) {
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setVisible(false);
|
||||
}
|
||||
++$c;
|
||||
}
|
||||
}
|
||||
while ($c <= $maxCol) {
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
|
||||
++$c;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!$this->_readDataOnly) && (isset($sheet->Rows))) {
|
||||
// Row Heights
|
||||
$rowAttributes = $sheet->Rows->attributes();
|
||||
$defaultHeight = $rowAttributes['DefaultSizePts'];
|
||||
$r = 0;
|
||||
|
||||
foreach($sheet->Rows->RowInfo as $rowOverride) {
|
||||
$rowAttributes = $rowOverride->attributes();
|
||||
$row = $rowAttributes['No'];
|
||||
$rowHeight = $rowAttributes['Unit'];
|
||||
$hidden = ((isset($rowAttributes['Hidden'])) && ($rowAttributes['Hidden'] == '1')) ? true : false;
|
||||
$rowCount = (isset($rowAttributes['Count'])) ? $rowAttributes['Count'] : 1;
|
||||
while ($r < $row) {
|
||||
++$r;
|
||||
$objPHPExcel->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight);
|
||||
}
|
||||
while (($r < ($row+$rowCount)) && ($r < $maxRow)) {
|
||||
++$r;
|
||||
$objPHPExcel->getActiveSheet()->getRowDimension($r)->setRowHeight($rowHeight);
|
||||
if ($hidden) {
|
||||
$objPHPExcel->getActiveSheet()->getRowDimension($r)->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
while ($r < $maxRow) {
|
||||
++$r;
|
||||
$objPHPExcel->getActiveSheet()->getRowDimension($r)->setRowHeight($defaultHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Merged Cells in this worksheet
|
||||
if (isset($sheet->MergedRegions)) {
|
||||
foreach($sheet->MergedRegions->Merge as $mergeCells) {
|
||||
if (strpos($mergeCells,':') !== FALSE) {
|
||||
$objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$worksheetID++;
|
||||
}
|
||||
|
||||
// Loop through definedNames (global named ranges)
|
||||
if (isset($gnmXML->Names)) {
|
||||
foreach($gnmXML->Names->Name as $namedRange) {
|
||||
$name = (string) $namedRange->name;
|
||||
$range = (string) $namedRange->value;
|
||||
if (stripos($range, '#REF!') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$range = explode('!',$range);
|
||||
$range[0] = trim($range[0],"'");;
|
||||
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
|
||||
$extractedRange = str_replace('$', '', $range[1]);
|
||||
$objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
|
||||
private static function _parseBorderAttributes($borderAttributes)
|
||||
{
|
||||
$styleArray = array();
|
||||
|
||||
if (isset($borderAttributes["Color"])) {
|
||||
$RGB = self::_parseGnumericColour($borderAttributes["Color"]);
|
||||
$styleArray['color']['rgb'] = $RGB;
|
||||
}
|
||||
|
||||
switch ($borderAttributes["Style"]) {
|
||||
case '0' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE;
|
||||
break;
|
||||
case '1' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case '2' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
|
||||
break;
|
||||
case '4' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED;
|
||||
break;
|
||||
case '5' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK;
|
||||
break;
|
||||
case '6' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE;
|
||||
break;
|
||||
case '7' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED;
|
||||
break;
|
||||
case '9' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT;
|
||||
break;
|
||||
case '10' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
|
||||
break;
|
||||
case '11' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT;
|
||||
break;
|
||||
case '12' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
|
||||
break;
|
||||
case '13' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
|
||||
break;
|
||||
case '3' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
|
||||
break;
|
||||
case '8' :
|
||||
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
|
||||
break;
|
||||
}
|
||||
return $styleArray;
|
||||
}
|
||||
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText($is);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
private static function _parseGnumericColour($gnmColour) {
|
||||
list($gnmR,$gnmG,$gnmB) = explode(':',$gnmColour);
|
||||
$gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2);
|
||||
$gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2);
|
||||
$gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2);
|
||||
$RGB = $gnmR.$gnmG.$gnmB;
|
||||
// echo 'Excel Colour: ',$RGB,'<br />';
|
||||
return $RGB;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,478 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_HTML
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding = 'ANSI';
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_formats = array( 'h1' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 24,
|
||||
),
|
||||
), // Bold, 24pt
|
||||
'h2' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 18,
|
||||
),
|
||||
), // Bold, 18pt
|
||||
'h3' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 13.5,
|
||||
),
|
||||
), // Bold, 13.5pt
|
||||
'h4' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 12,
|
||||
),
|
||||
), // Bold, 12pt
|
||||
'h5' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 10,
|
||||
),
|
||||
), // Bold, 10pt
|
||||
'h6' => array( 'font' => array( 'bold' => true,
|
||||
'size' => 7.5,
|
||||
),
|
||||
), // Bold, 7.5pt
|
||||
'a' => array( 'font' => array( 'underline' => true,
|
||||
'color' => array( 'argb' => PHPExcel_Style_Color::COLOR_BLUE,
|
||||
),
|
||||
),
|
||||
), // Blue underlined
|
||||
'hr' => array( 'borders' => array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN,
|
||||
'color' => array( PHPExcel_Style_Color::COLOR_BLACK,
|
||||
),
|
||||
),
|
||||
),
|
||||
), // Bottom border
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_HTML
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Read sample data (first 2 KB will do)
|
||||
$fh = fopen($pFilename, 'r');
|
||||
$data = fread($fh, 2048);
|
||||
fclose($fh);
|
||||
|
||||
if ((strpos('<',$data) !== FALSE) &&
|
||||
(strlen($data) !== strlen(strip_tags($data)))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'ANSI')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
// Data Array used for testing only, should write to PHPExcel object on completion of tests
|
||||
private $_dataArray = array();
|
||||
|
||||
private $_tableLevel = 0;
|
||||
private $_nestedColumn = array('A');
|
||||
|
||||
private function _setTableStartColumn($column) {
|
||||
if ($this->_tableLevel == 0)
|
||||
$column = 'A';
|
||||
++$this->_tableLevel;
|
||||
$this->_nestedColumn[$this->_tableLevel] = $column;
|
||||
|
||||
return $this->_nestedColumn[$this->_tableLevel];
|
||||
}
|
||||
|
||||
private function _getTableStartColumn() {
|
||||
return $this->_nestedColumn[$this->_tableLevel];
|
||||
}
|
||||
|
||||
private function _releaseTableStartColumn() {
|
||||
--$this->_tableLevel;
|
||||
return array_pop($this->_nestedColumn);
|
||||
}
|
||||
|
||||
private function _flushCell($sheet,$column,$row,&$cellContent) {
|
||||
if (is_string($cellContent)) {
|
||||
// Simple String content
|
||||
if (trim($cellContent) > '') {
|
||||
// Only actually write it if there's content in the string
|
||||
echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
|
||||
// Write to worksheet to be done here...
|
||||
// ... we return the cell so we can mess about with styles more easily
|
||||
$cell = $sheet->setCellValue($column.$row,$cellContent,true);
|
||||
$this->_dataArray[$row][$column] = $cellContent;
|
||||
}
|
||||
} else {
|
||||
// We have a Rich Text run
|
||||
// TODO
|
||||
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
|
||||
}
|
||||
$cellContent = (string) '';
|
||||
}
|
||||
|
||||
private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){
|
||||
foreach($element->childNodes as $child){
|
||||
if ($child instanceof DOMText) {
|
||||
$domText = preg_replace('/\s+/',' ',trim($child->nodeValue));
|
||||
if (is_string($cellContent)) {
|
||||
// simply append the text if the cell content is a plain text string
|
||||
$cellContent .= $domText;
|
||||
} else {
|
||||
// but if we have a rich text run instead, we need to append it correctly
|
||||
// TODO
|
||||
}
|
||||
} elseif($child instanceof DOMElement) {
|
||||
echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
|
||||
|
||||
$attributeArray = array();
|
||||
foreach($child->attributes as $attribute) {
|
||||
echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
|
||||
$attributeArray[$attribute->name] = $attribute->value;
|
||||
}
|
||||
|
||||
switch($child->nodeName) {
|
||||
case 'meta' :
|
||||
foreach($attributeArray as $attributeName => $attributeValue) {
|
||||
switch($attributeName) {
|
||||
case 'content':
|
||||
// TODO
|
||||
// Extract character set, so we can convert to UTF-8 if required
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
break;
|
||||
case 'title' :
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
$sheet->setTitle($cellContent);
|
||||
$cellContent = '';
|
||||
break;
|
||||
case 'span' :
|
||||
case 'div' :
|
||||
case 'font' :
|
||||
case 'i' :
|
||||
case 'em' :
|
||||
case 'strong':
|
||||
case 'b' :
|
||||
echo 'STYLING, SPAN OR DIV<br />';
|
||||
if ($cellContent > '')
|
||||
$cellContent .= ' ';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
if ($cellContent > '')
|
||||
$cellContent .= ' ';
|
||||
echo 'END OF STYLING, SPAN OR DIV<br />';
|
||||
break;
|
||||
case 'hr' :
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
++$row;
|
||||
if (isset($this->_formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
|
||||
} else {
|
||||
$cellContent = '----------';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
}
|
||||
++$row;
|
||||
case 'br' :
|
||||
if ($this->_tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
} else {
|
||||
// Otherwise flush our existing content and move the row cursor on
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
++$row;
|
||||
}
|
||||
echo 'HARD LINE BREAK: ' , '<br />';
|
||||
break;
|
||||
case 'a' :
|
||||
echo 'START OF HYPERLINK: ' , '<br />';
|
||||
foreach($attributeArray as $attributeName => $attributeValue) {
|
||||
switch($attributeName) {
|
||||
case 'href':
|
||||
echo 'Link to ' , $attributeValue , '<br />';
|
||||
$sheet->getCell($column.$row)->getHyperlink()->setUrl($attributeValue);
|
||||
if (isset($this->_formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$cellContent .= ' ';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF HYPERLINK:' , '<br />';
|
||||
break;
|
||||
case 'h1' :
|
||||
case 'h2' :
|
||||
case 'h3' :
|
||||
case 'h4' :
|
||||
case 'h5' :
|
||||
case 'h6' :
|
||||
case 'ol' :
|
||||
case 'ul' :
|
||||
case 'p' :
|
||||
if ($this->_tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
echo 'LIST ENTRY: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF LIST ENTRY:' , '<br />';
|
||||
} else {
|
||||
if ($cellContent > '') {
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
$row += 2;
|
||||
}
|
||||
echo 'START OF PARAGRAPH: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF PARAGRAPH:' , '<br />';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
|
||||
if (isset($this->_formats[$child->nodeName])) {
|
||||
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
|
||||
}
|
||||
|
||||
$row += 2;
|
||||
$column = 'A';
|
||||
}
|
||||
break;
|
||||
case 'li' :
|
||||
if ($this->_tableLevel > 0) {
|
||||
// If we're inside a table, replace with a \n
|
||||
$cellContent .= "\n";
|
||||
echo 'LIST ENTRY: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF LIST ENTRY:' , '<br />';
|
||||
} else {
|
||||
if ($cellContent > '') {
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
}
|
||||
++$row;
|
||||
echo 'LIST ENTRY: ' , '<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF LIST ENTRY:' , '<br />';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
$column = 'A';
|
||||
}
|
||||
break;
|
||||
case 'table' :
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
$column = $this->_setTableStartColumn($column);
|
||||
echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
||||
if ($this->_tableLevel > 1)
|
||||
--$row;
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
||||
$column = $this->_releaseTableStartColumn();
|
||||
if ($this->_tableLevel > 1) {
|
||||
++$column;
|
||||
} else {
|
||||
++$row;
|
||||
}
|
||||
break;
|
||||
case 'thead' :
|
||||
case 'tbody' :
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
break;
|
||||
case 'tr' :
|
||||
++$row;
|
||||
$column = $this->_getTableStartColumn();
|
||||
$cellContent = '';
|
||||
echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
||||
break;
|
||||
case 'th' :
|
||||
case 'td' :
|
||||
echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
||||
$this->_flushCell($sheet,$column,$row,$cellContent);
|
||||
++$column;
|
||||
break;
|
||||
case 'body' :
|
||||
$row = 1;
|
||||
$column = 'A';
|
||||
$content = '';
|
||||
$this->_tableLevel = 0;
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
break;
|
||||
default:
|
||||
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
if (!is_file($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! The given file is not a regular file.");
|
||||
}
|
||||
|
||||
// Create new PHPExcel
|
||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||
|
||||
// Create a new DOM object
|
||||
$dom = new domDocument;
|
||||
// Load the HTML file into the DOM object
|
||||
$loaded = $dom->loadHTMLFile($pFilename);
|
||||
if ($loaded === false) {
|
||||
throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document');
|
||||
}
|
||||
|
||||
// Discard white space
|
||||
$dom->preserveWhiteSpace = false;
|
||||
|
||||
|
||||
$row = 0;
|
||||
$column = 'A';
|
||||
$content = '';
|
||||
$this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content);
|
||||
|
||||
echo '<hr />';
|
||||
var_dump($this->_dataArray);
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_HTML
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
/**
|
||||
* Should this cell be read?
|
||||
*
|
||||
* @param $column String column index
|
||||
* @param $row Row index
|
||||
* @param $worksheetName Optional worksheet name
|
||||
* @return boolean
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '');
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReader
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename);
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename);
|
||||
}
|
|
@ -0,0 +1,618 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_OOCalc
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_styles = array();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_OOCalc
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Check if zip class exists
|
||||
if (!class_exists('ZipArchive',FALSE)) {
|
||||
throw new PHPExcel_Reader_Exception("ZipArchive library is not enabled");
|
||||
}
|
||||
|
||||
// Load file
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($pFilename) === true) {
|
||||
// check if it is an OOXML archive
|
||||
$stat = $zip->statName('mimetype');
|
||||
if ($stat && ($stat['size'] <= 255)) {
|
||||
$mimeType = $zip->getFromName($stat['name']);
|
||||
} else {
|
||||
$zip->close();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
|
||||
return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet');
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetNames($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$worksheetNames = array();
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($pFilename) === true) {
|
||||
|
||||
$xml = simplexml_load_string($zip->getFromName("content.xml"));
|
||||
$namespacesContent = $xml->getNamespaces(true);
|
||||
|
||||
$workbook = $xml->children($namespacesContent['office']);
|
||||
foreach($workbook->body->spreadsheet as $workbookData) {
|
||||
$workbookData = $workbookData->children($namespacesContent['table']);
|
||||
foreach($workbookData->table as $worksheetDataSet) {
|
||||
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
|
||||
|
||||
$worksheetNames[] = $worksheetDataAttributes['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
|
||||
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
|
||||
$styleAttributeValue = strtolower($styleAttributeValue);
|
||||
foreach($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
$styleAttributeValue = $style;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$worksheetInfo = array();
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($pFilename) === true) {
|
||||
|
||||
$xml = simplexml_load_string($zip->getFromName("content.xml"));
|
||||
$namespacesContent = $xml->getNamespaces(true);
|
||||
|
||||
$workbook = $xml->children($namespacesContent['office']);
|
||||
foreach($workbook->body->spreadsheet as $workbookData) {
|
||||
$workbookData = $workbookData->children($namespacesContent['table']);
|
||||
foreach($workbookData->table as $worksheetDataSet) {
|
||||
$worksheetData = $worksheetDataSet->children($namespacesContent['table']);
|
||||
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
|
||||
|
||||
$tmpInfo = array();
|
||||
$tmpInfo['worksheetName'] = (string) $worksheetDataAttributes['name'];
|
||||
$tmpInfo['lastColumnLetter'] = 'A';
|
||||
$tmpInfo['lastColumnIndex'] = 0;
|
||||
$tmpInfo['totalRows'] = 0;
|
||||
$tmpInfo['totalColumns'] = 0;
|
||||
|
||||
$rowIndex = 0;
|
||||
foreach ($worksheetData as $key => $rowData) {
|
||||
switch ($key) {
|
||||
case 'table-row' :
|
||||
$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
|
||||
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
|
||||
$rowDataTableAttributes['number-rows-repeated'] : 1;
|
||||
$columnIndex = 0;
|
||||
|
||||
foreach ($rowData as $key => $cellData) {
|
||||
$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
|
||||
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
|
||||
$cellDataTableAttributes['number-columns-repeated'] : 1;
|
||||
$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
|
||||
if (isset($cellDataOfficeAttributes['value-type'])) {
|
||||
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex + $colRepeats - 1);
|
||||
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex + $rowRepeats);
|
||||
}
|
||||
$columnIndex += $colRepeats;
|
||||
}
|
||||
$rowIndex += $rowRepeats;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
|
||||
$tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
|
||||
|
||||
$worksheetInfo[] = $tmpInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$timezoneObj = new DateTimeZone('Europe/London');
|
||||
$GMT = new DateTimeZone('UTC');
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($pFilename) === true) {
|
||||
// echo '<h1>Meta Information</h1>';
|
||||
$xml = simplexml_load_string($zip->getFromName("meta.xml"));
|
||||
$namespacesMeta = $xml->getNamespaces(true);
|
||||
// echo '<pre>';
|
||||
// print_r($namespacesMeta);
|
||||
// echo '</pre><hr />';
|
||||
|
||||
$docProps = $objPHPExcel->getProperties();
|
||||
$officeProperty = $xml->children($namespacesMeta['office']);
|
||||
foreach($officeProperty as $officePropertyData) {
|
||||
$officePropertyDC = array();
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
|
||||
}
|
||||
foreach($officePropertyDC as $propertyName => $propertyValue) {
|
||||
switch ($propertyName) {
|
||||
case 'title' :
|
||||
$docProps->setTitle($propertyValue);
|
||||
break;
|
||||
case 'subject' :
|
||||
$docProps->setSubject($propertyValue);
|
||||
break;
|
||||
case 'creator' :
|
||||
$docProps->setCreator($propertyValue);
|
||||
$docProps->setLastModifiedBy($propertyValue);
|
||||
break;
|
||||
case 'date' :
|
||||
$creationDate = strtotime($propertyValue);
|
||||
$docProps->setCreated($creationDate);
|
||||
$docProps->setModified($creationDate);
|
||||
break;
|
||||
case 'description' :
|
||||
$docProps->setDescription($propertyValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$officePropertyMeta = array();
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
|
||||
}
|
||||
foreach($officePropertyMeta as $propertyName => $propertyValue) {
|
||||
$propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
|
||||
switch ($propertyName) {
|
||||
case 'initial-creator' :
|
||||
$docProps->setCreator($propertyValue);
|
||||
break;
|
||||
case 'keyword' :
|
||||
$docProps->setKeywords($propertyValue);
|
||||
break;
|
||||
case 'creation-date' :
|
||||
$creationDate = strtotime($propertyValue);
|
||||
$docProps->setCreated($creationDate);
|
||||
break;
|
||||
case 'user-defined' :
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
|
||||
foreach ($propertyValueAttributes as $key => $value) {
|
||||
if ($key == 'name') {
|
||||
$propertyValueName = (string) $value;
|
||||
} elseif($key == 'value-type') {
|
||||
switch ($value) {
|
||||
case 'date' :
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date');
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
|
||||
break;
|
||||
case 'boolean' :
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'bool');
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
|
||||
break;
|
||||
case 'float' :
|
||||
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'r4');
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
|
||||
break;
|
||||
default :
|
||||
$propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
|
||||
}
|
||||
}
|
||||
}
|
||||
$docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// echo '<h1>Workbook Content</h1>';
|
||||
$xml = simplexml_load_string($zip->getFromName("content.xml"));
|
||||
$namespacesContent = $xml->getNamespaces(true);
|
||||
// echo '<pre>';
|
||||
// print_r($namespacesContent);
|
||||
// echo '</pre><hr />';
|
||||
|
||||
$workbook = $xml->children($namespacesContent['office']);
|
||||
foreach($workbook->body->spreadsheet as $workbookData) {
|
||||
$workbookData = $workbookData->children($namespacesContent['table']);
|
||||
$worksheetID = 0;
|
||||
foreach($workbookData->table as $worksheetDataSet) {
|
||||
$worksheetData = $worksheetDataSet->children($namespacesContent['table']);
|
||||
// print_r($worksheetData);
|
||||
// echo '<br />';
|
||||
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
|
||||
// print_r($worksheetDataAttributes);
|
||||
// echo '<br />';
|
||||
if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) &&
|
||||
(!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// echo '<h2>Worksheet '.$worksheetDataAttributes['name'].'</h2>';
|
||||
// Create new Worksheet
|
||||
$objPHPExcel->createSheet();
|
||||
$objPHPExcel->setActiveSheetIndex($worksheetID);
|
||||
if (isset($worksheetDataAttributes['name'])) {
|
||||
$worksheetName = (string) $worksheetDataAttributes['name'];
|
||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
||||
// formula cells... during the load, all formulae should be correct, and we're simply
|
||||
// bringing the worksheet name in line with the formula, not the reverse
|
||||
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false);
|
||||
}
|
||||
|
||||
$rowID = 1;
|
||||
foreach($worksheetData as $key => $rowData) {
|
||||
// echo '<b>'.$key.'</b><br />';
|
||||
switch ($key) {
|
||||
case 'table-header-rows':
|
||||
foreach ($rowData as $key=>$cellData) {
|
||||
$rowData = $cellData;
|
||||
break;
|
||||
}
|
||||
case 'table-row' :
|
||||
$rowDataTableAttributes = $rowData->attributes($namespacesContent['table']);
|
||||
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
|
||||
$rowDataTableAttributes['number-rows-repeated'] : 1;
|
||||
$columnID = 'A';
|
||||
foreach($rowData as $key => $cellData) {
|
||||
if ($this->getReadFilter() !== NULL) {
|
||||
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// echo '<b>'.$columnID.$rowID.'</b><br />';
|
||||
$cellDataText = (isset($namespacesContent['text'])) ?
|
||||
$cellData->children($namespacesContent['text']) :
|
||||
'';
|
||||
$cellDataOffice = $cellData->children($namespacesContent['office']);
|
||||
$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
|
||||
$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
|
||||
|
||||
// echo 'Office Attributes: ';
|
||||
// print_r($cellDataOfficeAttributes);
|
||||
// echo '<br />Table Attributes: ';
|
||||
// print_r($cellDataTableAttributes);
|
||||
// echo '<br />Cell Data Text';
|
||||
// print_r($cellDataText);
|
||||
// echo '<br />';
|
||||
//
|
||||
$type = $formatting = $hyperlink = null;
|
||||
$hasCalculatedValue = false;
|
||||
$cellDataFormula = '';
|
||||
if (isset($cellDataTableAttributes['formula'])) {
|
||||
$cellDataFormula = $cellDataTableAttributes['formula'];
|
||||
$hasCalculatedValue = true;
|
||||
}
|
||||
|
||||
if (isset($cellDataOffice->annotation)) {
|
||||
// echo 'Cell has comment<br />';
|
||||
$annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
|
||||
$textArray = array();
|
||||
foreach($annotationText as $t) {
|
||||
foreach($t->span as $text) {
|
||||
$textArray[] = (string)$text;
|
||||
}
|
||||
}
|
||||
$text = implode("\n",$textArray);
|
||||
// echo $text,'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
|
||||
// ->setAuthor( $author )
|
||||
->setText($this->_parseRichText($text) );
|
||||
}
|
||||
|
||||
if (isset($cellDataText->p)) {
|
||||
// Consolidate if there are multiple p records (maybe with spans as well)
|
||||
$dataArray = array();
|
||||
// Text can have multiple text:p and within those, multiple text:span.
|
||||
// text:p newlines, but text:span does not.
|
||||
// Also, here we assume there is no text data is span fields are specified, since
|
||||
// we have no way of knowing proper positioning anyway.
|
||||
foreach ($cellDataText->p as $pData) {
|
||||
if (isset($pData->span)) {
|
||||
// span sections do not newline, so we just create one large string here
|
||||
$spanSection = "";
|
||||
foreach ($pData->span as $spanData) {
|
||||
$spanSection .= $spanData;
|
||||
}
|
||||
array_push($dataArray, $spanSection);
|
||||
} else {
|
||||
array_push($dataArray, $pData);
|
||||
}
|
||||
}
|
||||
$allCellDataText = implode($dataArray, "\n");
|
||||
|
||||
// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
|
||||
switch ($cellDataOfficeAttributes['value-type']) {
|
||||
case 'string' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
$dataValue = $allCellDataText;
|
||||
if (isset($dataValue->a)) {
|
||||
$dataValue = $dataValue->a;
|
||||
$cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']);
|
||||
$hyperlink = $cellXLinkAttributes['href'];
|
||||
}
|
||||
break;
|
||||
case 'boolean' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
$dataValue = ($allCellDataText == 'TRUE') ? True : False;
|
||||
break;
|
||||
case 'percentage' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
||||
if (floor($dataValue) == $dataValue) {
|
||||
$dataValue = (integer) $dataValue;
|
||||
}
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00;
|
||||
break;
|
||||
case 'currency' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
||||
if (floor($dataValue) == $dataValue) {
|
||||
$dataValue = (integer) $dataValue;
|
||||
}
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
|
||||
break;
|
||||
case 'float' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
||||
if (floor($dataValue) == $dataValue) {
|
||||
if ($dataValue = (integer) $dataValue)
|
||||
$dataValue = (integer) $dataValue;
|
||||
else
|
||||
$dataValue = (float) $dataValue;
|
||||
}
|
||||
break;
|
||||
case 'date' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
|
||||
$dateObj->setTimeZone($timezoneObj);
|
||||
list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s'));
|
||||
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second);
|
||||
if ($dataValue != floor($dataValue)) {
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
|
||||
} else {
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15;
|
||||
}
|
||||
break;
|
||||
case 'time' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS'))));
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
|
||||
break;
|
||||
}
|
||||
// echo 'Data value is '.$dataValue.'<br />';
|
||||
// if ($hyperlink !== NULL) {
|
||||
// echo 'Hyperlink is '.$hyperlink.'<br />';
|
||||
// }
|
||||
} else {
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
$dataValue = NULL;
|
||||
}
|
||||
|
||||
if ($hasCalculatedValue) {
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
// echo 'Formula: '.$cellDataFormula.'<br />';
|
||||
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
$tKey = false;
|
||||
foreach($temp as &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if ($tKey = !$tKey) {
|
||||
$value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value);
|
||||
$value = preg_replace('/\[\.(.*)\]/Ui','$1',$value);
|
||||
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"',$temp);
|
||||
// echo 'Adjusted Formula: '.$cellDataFormula.'<br />';
|
||||
}
|
||||
|
||||
$colRepeats = (isset($cellDataTableAttributes['number-columns-repeated'])) ?
|
||||
$cellDataTableAttributes['number-columns-repeated'] : 1;
|
||||
if ($type !== NULL) {
|
||||
for ($i = 0; $i < $colRepeats; ++$i) {
|
||||
if ($i > 0) {
|
||||
++$columnID;
|
||||
}
|
||||
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
|
||||
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
|
||||
$rID = $rowID + $rowAdjust;
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
|
||||
if ($hasCalculatedValue) {
|
||||
// echo 'Forumla result is '.$dataValue.'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);
|
||||
}
|
||||
if ($formatting !== NULL) {
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
|
||||
} else {
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
|
||||
}
|
||||
if ($hyperlink !== NULL) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merged cells
|
||||
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
|
||||
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) {
|
||||
$columnTo = $columnID;
|
||||
if (isset($cellDataTableAttributes['number-columns-spanned'])) {
|
||||
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
|
||||
}
|
||||
$rowTo = $rowID;
|
||||
if (isset($cellDataTableAttributes['number-rows-spanned'])) {
|
||||
$rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1;
|
||||
}
|
||||
$cellRange = $columnID.$rowID.':'.$columnTo.$rowTo;
|
||||
$objPHPExcel->getActiveSheet()->mergeCells($cellRange);
|
||||
}
|
||||
}
|
||||
|
||||
++$columnID;
|
||||
}
|
||||
$rowID += $rowRepeats;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++$worksheetID;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
|
||||
private function _parseRichText($is = '') {
|
||||
$value = new PHPExcel_RichText();
|
||||
|
||||
$value->createText($is);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,469 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_SYLK
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding = 'ANSI';
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_formats = array();
|
||||
|
||||
/**
|
||||
* Format Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_format = 0;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Read sample data (first 2 KB will do)
|
||||
$fh = fopen($pFilename, 'r');
|
||||
$data = fread($fh, 2048);
|
||||
fclose($fh);
|
||||
|
||||
// Count delimiters in file
|
||||
$delimiterCount = substr_count($data, ';');
|
||||
if ($delimiterCount < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Analyze first line looking for ID; signature
|
||||
$lines = explode("\n", $data);
|
||||
if (substr($lines[0],0,4) != 'ID;P') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'ANSI')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function listWorksheetInfo($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Open file
|
||||
$fileHandle = fopen($pFilename, 'r');
|
||||
if ($fileHandle === false) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
|
||||
}
|
||||
|
||||
$worksheetInfo = array();
|
||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||
$worksheetInfo[0]['totalRows'] = 0;
|
||||
$worksheetInfo[0]['totalColumns'] = 0;
|
||||
|
||||
// Loop through file
|
||||
$rowData = array();
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
$rowIndex = 0;
|
||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||
$columnIndex = 0;
|
||||
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t",str_replace('?',';',str_replace(';',"\t",str_replace(';;','?',rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
if ($dataType == 'C') {
|
||||
// Read cell value data
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' :
|
||||
$columnIndex = substr($rowDatum,1) - 1;
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' :
|
||||
$rowIndex = substr($rowDatum,1);
|
||||
break;
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
|
||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
return $worksheetInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Create new PHPExcel
|
||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
|
||||
// Open file
|
||||
$fileHandle = fopen($pFilename, 'r');
|
||||
if ($fileHandle === false) {
|
||||
throw new PHPExcel_Reader_Exception("Could not open file $pFilename for reading.");
|
||||
}
|
||||
|
||||
// Loop through file
|
||||
$rowData = array();
|
||||
$column = $row = '';
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
// Read shared styles
|
||||
if ($dataType == 'P') {
|
||||
$formatArray = array();
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
|
||||
break;
|
||||
case 'E' :
|
||||
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
|
||||
break;
|
||||
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
|
||||
break;
|
||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I' : $formatArray['font']['italic'] = true;
|
||||
break;
|
||||
case 'D' : $formatArray['font']['bold'] = true;
|
||||
break;
|
||||
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_formats['P'.$this->_format++] = $formatArray;
|
||||
// Read cell value data
|
||||
} elseif ($dataType == 'C') {
|
||||
$hasCalculatedValue = false;
|
||||
$cellData = $cellDataFormula = '';
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
case 'K' : $cellData = substr($rowDatum,1);
|
||||
break;
|
||||
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
$key = false;
|
||||
foreach($temp as &$value) {
|
||||
// Only count/replace in alternate array entries
|
||||
if ($key = !$key) {
|
||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach($cellReferences as $cellReference) {
|
||||
$rowReference = $cellReference[2][0];
|
||||
// Empty R reference is the current row
|
||||
if ($rowReference == '') $rowReference = $row;
|
||||
// Bracketed R references are relative to the current row
|
||||
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
|
||||
$columnReference = $cellReference[4][0];
|
||||
// Empty C reference is the current column
|
||||
if ($columnReference == '') $columnReference = $column;
|
||||
// Bracketed C references are relative to the current column
|
||||
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
|
||||
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
|
||||
|
||||
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"',$temp);
|
||||
$hasCalculatedValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||
|
||||
// Set cell value
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
||||
if ($hasCalculatedValue) {
|
||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
|
||||
}
|
||||
// Read cell formatting
|
||||
} elseif ($dataType == 'F') {
|
||||
$formatStyle = $columnWidth = $styleSettings = '';
|
||||
$styleData = array();
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
case 'P' : $formatStyle = $rowDatum;
|
||||
break;
|
||||
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
|
||||
break;
|
||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I' : $styleData['font']['italic'] = true;
|
||||
break;
|
||||
case 'D' : $styleData['font']['bold'] = true;
|
||||
break;
|
||||
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (($formatStyle > '') && ($column > '') && ($row > '')) {
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
|
||||
}
|
||||
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
|
||||
}
|
||||
if ($columnWidth > '') {
|
||||
if ($startCol == $endCol) {
|
||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
} else {
|
||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
do {
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
|
||||
} while ($startCol != $endCol);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,695 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_ReferenceHelper (Singleton)
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_ReferenceHelper
|
||||
{
|
||||
/** Constants */
|
||||
/** Regular Expressions */
|
||||
const REFHELPER_REGEXP_CELLREF = '((\w*|\'[^!]*\')!)?(?<![:a-z\$])(\$?[a-z]{1,3}\$?\d+)(?=[^:!\d\'])';
|
||||
const REFHELPER_REGEXP_CELLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}\$?\d+):(\$?[a-z]{1,3}\$?\d+)';
|
||||
const REFHELPER_REGEXP_ROWRANGE = '((\w*|\'[^!]*\')!)?(\$?\d+):(\$?\d+)';
|
||||
const REFHELPER_REGEXP_COLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}):(\$?[a-z]{1,3})';
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var PHPExcel_ReferenceHelper
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* Get an instance of this class
|
||||
*
|
||||
* @return PHPExcel_ReferenceHelper
|
||||
*/
|
||||
public static function getInstance() {
|
||||
if (!isset(self::$_instance) || (self::$_instance === NULL)) {
|
||||
self::$_instance = new PHPExcel_ReferenceHelper();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_ReferenceHelper
|
||||
*/
|
||||
protected function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new column, updating all possible related data
|
||||
*
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to insert
|
||||
* @param int $pNumRows Number of rows to insert
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
|
||||
$remove = ($pNumCols < 0 || $pNumRows < 0);
|
||||
$aCellCollection = $pSheet->getCellCollection();
|
||||
|
||||
// Get coordinates of $pBefore
|
||||
$beforeColumn = 'A';
|
||||
$beforeRow = 1;
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
||||
$beforeColumnIndex = PHPExcel_Cell::columnIndexFromString($beforeColumn);
|
||||
|
||||
|
||||
// Clear cells if we are removing columns or rows
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
|
||||
// 1. Clear column strips if we are removing columns
|
||||
if ($pNumCols < 0 && $beforeColumnIndex - 2 + $pNumCols > 0) {
|
||||
for ($i = 1; $i <= $highestRow - 1; ++$i) {
|
||||
for ($j = $beforeColumnIndex - 1 + $pNumCols; $j <= $beforeColumnIndex - 2; ++$j) {
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex($j) . $i;
|
||||
$pSheet->removeConditionalStyles($coordinate);
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
|
||||
$pSheet->getCell($coordinate)->setXfIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Clear row strips if we are removing rows
|
||||
if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) {
|
||||
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
|
||||
for ($j = $beforeRow + $pNumRows; $j <= $beforeRow - 1; ++$j) {
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . $j;
|
||||
$pSheet->removeConditionalStyles($coordinate);
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
|
||||
$pSheet->getCell($coordinate)->setXfIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Loop through cells, bottom-up, and change cell coordinates
|
||||
while (($cellID = $remove ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
|
||||
$cell = $pSheet->getCell($cellID);
|
||||
$cellIndex = PHPExcel_Cell::columnIndexFromString($cell->getColumn());
|
||||
if ($cellIndex-1 + $pNumCols < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// New coordinates
|
||||
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows);
|
||||
|
||||
// Should the cell be updated? Move value and cellXf index from one cell to another.
|
||||
if (($cellIndex >= $beforeColumnIndex) &&
|
||||
($cell->getRow() >= $beforeRow)) {
|
||||
|
||||
// Update cell styles
|
||||
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
|
||||
|
||||
// Insert this cell at its new location
|
||||
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
// Formula should be adjusted
|
||||
$pSheet->getCell($newCoordinates)
|
||||
->setValue($this->updateFormulaReferences($cell->getValue(),
|
||||
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
|
||||
} else {
|
||||
// Formula should not be adjusted
|
||||
$pSheet->getCell($newCoordinates)->setValue($cell->getValue());
|
||||
}
|
||||
|
||||
// Clear the original cell
|
||||
$pSheet->getCellCacheController()->deleteCacheData($cellID);
|
||||
|
||||
} else {
|
||||
/* We don't need to update styles for rows/columns before our insertion position,
|
||||
but we do still need to adjust any formulae in those cells */
|
||||
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
// Formula should be adjusted
|
||||
$cell->setValue($this->updateFormulaReferences($cell->getValue(),
|
||||
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Duplicate styles for the newly inserted cells
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
|
||||
if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) {
|
||||
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
|
||||
|
||||
// Style
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex( $beforeColumnIndex - 2 ) . $i;
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
|
||||
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
|
||||
$pSheet->getConditionalStyles($coordinate) : false;
|
||||
for ($j = $beforeColumnIndex - 1; $j <= $beforeColumnIndex - 2 + $pNumCols; ++$j) {
|
||||
$pSheet->getCellByColumnAndRow($j, $i)->setXfIndex($xfIndex);
|
||||
if ($conditionalStyles) {
|
||||
$cloned = array();
|
||||
foreach ($conditionalStyles as $conditionalStyle) {
|
||||
$cloned[] = clone $conditionalStyle;
|
||||
}
|
||||
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($j) . $i, $cloned);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($pNumRows > 0 && $beforeRow - 1 > 0) {
|
||||
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
|
||||
|
||||
// Style
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
|
||||
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
|
||||
$pSheet->getConditionalStyles($coordinate) : false;
|
||||
for ($j = $beforeRow; $j <= $beforeRow - 1 + $pNumRows; ++$j) {
|
||||
$pSheet->getCell(PHPExcel_Cell::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex);
|
||||
if ($conditionalStyles) {
|
||||
$cloned = array();
|
||||
foreach ($conditionalStyles as $conditionalStyle) {
|
||||
$cloned[] = clone $conditionalStyle;
|
||||
}
|
||||
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($i) . $j, $cloned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: column dimensions
|
||||
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
|
||||
if (!empty($aColumnDimensions)) {
|
||||
foreach ($aColumnDimensions as $objColumnDimension) {
|
||||
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
|
||||
list($newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
||||
if ($objColumnDimension->getColumnIndex() != $newReference) {
|
||||
$objColumnDimension->setColumnIndex($newReference);
|
||||
}
|
||||
}
|
||||
$pSheet->refreshColumnDimensions();
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: row dimensions
|
||||
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
|
||||
if (!empty($aRowDimensions)) {
|
||||
foreach ($aRowDimensions as $objRowDimension) {
|
||||
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
|
||||
list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
||||
if ($objRowDimension->getRowIndex() != $newReference) {
|
||||
$objRowDimension->setRowIndex($newReference);
|
||||
}
|
||||
}
|
||||
$pSheet->refreshRowDimensions();
|
||||
|
||||
$copyDimension = $pSheet->getRowDimension($beforeRow - 1);
|
||||
for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) {
|
||||
$newDimension = $pSheet->getRowDimension($i);
|
||||
$newDimension->setRowHeight($copyDimension->getRowHeight());
|
||||
$newDimension->setVisible($copyDimension->getVisible());
|
||||
$newDimension->setOutlineLevel($copyDimension->getOutlineLevel());
|
||||
$newDimension->setCollapsed($copyDimension->getCollapsed());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: breaks
|
||||
$aBreaks = array_reverse($pSheet->getBreaks(), true);
|
||||
foreach ($aBreaks as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->setBreak( $newReference, $value );
|
||||
$pSheet->setBreak( $key, PHPExcel_Worksheet::BREAK_NONE );
|
||||
}
|
||||
}
|
||||
|
||||
// Update worksheet: comments
|
||||
$aComments = $pSheet->getComments();
|
||||
$aNewComments = array(); // the new array of all comments
|
||||
foreach ($aComments as $key => &$value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
$aNewComments[$newReference] = $value;
|
||||
}
|
||||
$pSheet->setComments($aNewComments); // replace the comments array
|
||||
|
||||
// Update worksheet: hyperlinks
|
||||
$aHyperlinkCollection = array_reverse($pSheet->getHyperlinkCollection(), true);
|
||||
foreach ($aHyperlinkCollection as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->setHyperlink( $newReference, $value );
|
||||
$pSheet->setHyperlink( $key, null );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: data validations
|
||||
$aDataValidationCollection = array_reverse($pSheet->getDataValidationCollection(), true);
|
||||
foreach ($aDataValidationCollection as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->setDataValidation( $newReference, $value );
|
||||
$pSheet->setDataValidation( $key, null );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: merge cells
|
||||
$aMergeCells = $pSheet->getMergeCells();
|
||||
$aNewMergeCells = array(); // the new array of all merge cells
|
||||
foreach ($aMergeCells as $key => &$value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
$aNewMergeCells[$newReference] = $newReference;
|
||||
}
|
||||
$pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array
|
||||
|
||||
|
||||
// Update worksheet: protected cells
|
||||
$aProtectedCells = array_reverse($pSheet->getProtectedCells(), true);
|
||||
foreach ($aProtectedCells as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->protectCells( $newReference, $value, true );
|
||||
$pSheet->unprotectCells( $key );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: autofilter
|
||||
$autoFilter = $pSheet->getAutoFilter();
|
||||
$autoFilterRange = $autoFilter->getRange();
|
||||
if (!empty($autoFilterRange)) {
|
||||
if ($pNumCols != 0) {
|
||||
$autoFilterColumns = array_keys($autoFilter->getColumns());
|
||||
if (count($autoFilterColumns) > 0) {
|
||||
list($column,$row) = sscanf($pBefore,'%[A-Z]%d');
|
||||
$columnIndex = PHPExcel_Cell::columnIndexFromString($column);
|
||||
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
|
||||
if ($columnIndex <= $rangeEnd[0]) {
|
||||
if ($pNumCols < 0) {
|
||||
// If we're actually deleting any columns that fall within the autofilter range,
|
||||
// then we delete any rules for those columns
|
||||
$deleteColumn = $columnIndex + $pNumCols - 1;
|
||||
$deleteCount = abs($pNumCols);
|
||||
for ($i = 1; $i <= $deleteCount; ++$i) {
|
||||
if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) {
|
||||
$autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn));
|
||||
}
|
||||
++$deleteColumn;
|
||||
}
|
||||
}
|
||||
$startCol = ($columnIndex > $rangeStart[0]) ? $columnIndex : $rangeStart[0];
|
||||
|
||||
// Shuffle columns in autofilter range
|
||||
if ($pNumCols > 0) {
|
||||
// For insert, we shuffle from end to beginning to avoid overwriting
|
||||
$startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
|
||||
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
|
||||
|
||||
$startColRef = $startCol;
|
||||
$endColRef = $rangeEnd[0];
|
||||
$toColRef = $rangeEnd[0]+$pNumCols;
|
||||
|
||||
do {
|
||||
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1),PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
|
||||
--$endColRef;
|
||||
--$toColRef;
|
||||
} while ($startColRef <= $endColRef);
|
||||
} else {
|
||||
// For delete, we shuffle from beginning to end to avoid overwriting
|
||||
$startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
|
||||
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
|
||||
do {
|
||||
$autoFilter->shiftColumn($startColID,$toColID);
|
||||
++$startColID;
|
||||
++$toColID;
|
||||
} while ($startColID != $endColID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) );
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: freeze pane
|
||||
if ($pSheet->getFreezePane() != '') {
|
||||
$pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) );
|
||||
}
|
||||
|
||||
|
||||
// Page setup
|
||||
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
|
||||
$pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) );
|
||||
}
|
||||
|
||||
|
||||
// Update worksheet: drawings
|
||||
$aDrawings = $pSheet->getDrawingCollection();
|
||||
foreach ($aDrawings as $objDrawing) {
|
||||
$newReference = $this->updateCellReference($objDrawing->getCoordinates(), $pBefore, $pNumCols, $pNumRows);
|
||||
if ($objDrawing->getCoordinates() != $newReference) {
|
||||
$objDrawing->setCoordinates($newReference);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update workbook: named ranges
|
||||
if (count($pSheet->getParent()->getNamedRanges()) > 0) {
|
||||
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
|
||||
if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) {
|
||||
$namedRange->setRange(
|
||||
$this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Garbage collect
|
||||
$pSheet->garbageCollect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update references within formulas
|
||||
*
|
||||
* @param string $pFormula Formula to update
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to insert
|
||||
* @param int $pNumRows Number of rows to insert
|
||||
* @return string Updated formula
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') {
|
||||
// Update cell references in the formula
|
||||
$formulaBlocks = explode('"',$pFormula);
|
||||
$i = false;
|
||||
foreach($formulaBlocks as &$formulaBlock) {
|
||||
// Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode)
|
||||
if ($i = !$i) {
|
||||
$adjustCount = 0;
|
||||
$newCellTokens = $cellTokens = array();
|
||||
// Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3].':'.$match[4];
|
||||
$modified3 = substr($this->updateCellReference('$A'.$match[3],$pBefore,$pNumCols,$pNumRows),2);
|
||||
$modified4 = substr($this->updateCellReference('$A'.$match[4],$pBefore,$pNumCols,$pNumRows),2);
|
||||
|
||||
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3.':'.$modified4;
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = 100000;
|
||||
$row = 10000000+trim($match[3],'$');
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<!\d)'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3].':'.$match[4];
|
||||
$modified3 = substr($this->updateCellReference($match[3].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
|
||||
$modified4 = substr($this->updateCellReference($match[4].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
|
||||
|
||||
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3.':'.$modified4;
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3],'$')) + 100000;
|
||||
$row = 10000000;
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?![A-Z])/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3].':'.$match[4];
|
||||
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
|
||||
$modified4 = $this->updateCellReference($match[4],$pBefore,$pNumCols,$pNumRows);
|
||||
|
||||
if ($match[3].$match[4] !== $modified3.$modified4) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3.':'.$modified4;
|
||||
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
|
||||
$row = trim($row,'$') + 10000000;
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search for cell references (e.g. 'Sheet1'!A3 or C5) with or without $ absolutes (e.g. $A1 or C$5)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3];
|
||||
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
|
||||
|
||||
if ($match[3] !== $modified3) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3;
|
||||
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
|
||||
$row = trim($row,'$') + 10000000;
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($adjustCount > 0) {
|
||||
if ($pNumCols > 0) {
|
||||
krsort($cellTokens);
|
||||
krsort($newCellTokens);
|
||||
} else {
|
||||
ksort($cellTokens);
|
||||
ksort($newCellTokens);
|
||||
}
|
||||
// Update cell references in the formula
|
||||
$formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($formulaBlock);
|
||||
|
||||
// Then rebuild the formula string
|
||||
return implode('"',$formulaBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cell reference
|
||||
*
|
||||
* @param string $pCellRange Cell range
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell range
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
// Is it in another worksheet? Will not have to update anything.
|
||||
if (strpos($pCellRange, "!") !== false) {
|
||||
return $pCellRange;
|
||||
// Is it a range or a single cell?
|
||||
} elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) {
|
||||
// Single cell
|
||||
return $this->_updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);
|
||||
} elseif (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
|
||||
// Range
|
||||
return $this->_updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows);
|
||||
} else {
|
||||
// Return original
|
||||
return $pCellRange;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update named formulas (i.e. containing worksheet references / named ranges)
|
||||
*
|
||||
* @param PHPExcel $pPhpExcel Object to update
|
||||
* @param string $oldName Old name (name to replace)
|
||||
* @param string $newName New name
|
||||
*/
|
||||
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '') {
|
||||
if ($oldName == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
|
||||
foreach ($sheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
if (($cell !== NULL) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) {
|
||||
$formula = $cell->getValue();
|
||||
if (strpos($formula, $oldName) !== false) {
|
||||
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
|
||||
$formula = str_replace($oldName . "!", $newName . "!", $formula);
|
||||
$cell->setValueExplicit($formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cell range
|
||||
*
|
||||
* @param string $pCellRange Cell range (e.g. 'B2:D4', 'B:C' or '2:3')
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell range
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
|
||||
// Update range
|
||||
$range = PHPExcel_Cell::splitRange($pCellRange);
|
||||
$ic = count($range);
|
||||
for ($i = 0; $i < $ic; ++$i) {
|
||||
$jc = count($range[$i]);
|
||||
for ($j = 0; $j < $jc; ++$j) {
|
||||
if (ctype_alpha($range[$i][$j])) {
|
||||
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
|
||||
$range[$i][$j] = $r[0];
|
||||
} elseif(ctype_digit($range[$i][$j])) {
|
||||
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
|
||||
$range[$i][$j] = $r[1];
|
||||
} else {
|
||||
$range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recreate range string
|
||||
return PHPExcel_Cell::buildRange($range);
|
||||
} else {
|
||||
throw new Exception("Only cell ranges may be passed to this method.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single cell reference
|
||||
*
|
||||
* @param string $pCellReference Single cell reference
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell reference
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
|
||||
// Get coordinates of $pBefore
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
||||
|
||||
// Get coordinates of $pCellReference
|
||||
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString( $pCellReference );
|
||||
|
||||
// Verify which parts should be updated
|
||||
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') &&
|
||||
PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn));
|
||||
|
||||
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') &&
|
||||
$newRow >= $beforeRow);
|
||||
|
||||
// Create new column reference
|
||||
if ($updateColumn) {
|
||||
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols );
|
||||
}
|
||||
|
||||
// Create new row reference
|
||||
if ($updateRow) {
|
||||
$newRow = $newRow + $pNumRows;
|
||||
}
|
||||
|
||||
// Return new reference
|
||||
return $newColumn . $newRow;
|
||||
} else {
|
||||
throw new Exception("Only single cell references may be passed to this method.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* __clone implementation. Cloning should not be allowed in a Singleton!
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public final function __clone() {
|
||||
throw new Exception("Cloning a Singleton is not allowed!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Rich text elements
|
||||
*
|
||||
* @var PHPExcel_RichText_ITextElement[]
|
||||
*/
|
||||
private $_richTextElements;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText instance
|
||||
*
|
||||
* @param PHPExcel_Cell $pParent
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(PHPExcel_Cell $pCell = null)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_richTextElements = array();
|
||||
|
||||
// Rich-Text string attached to cell?
|
||||
if ($pCell !== NULL) {
|
||||
// Add cell text and style
|
||||
if ($pCell->getValue() != "") {
|
||||
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
|
||||
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
|
||||
$this->addText($objRun);
|
||||
}
|
||||
|
||||
// Set parent value
|
||||
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param PHPExcel_RichText_ITextElement $pText Rich text element
|
||||
* @throws Exception
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function addText(PHPExcel_RichText_ITextElement $pText = null)
|
||||
{
|
||||
$this->_richTextElements[] = $pText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPExcel_RichText_TextElement
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
$objText = new PHPExcel_RichText_TextElement($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPExcel_RichText_Run
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
$objText = new PHPExcel_RichText_Run($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop through all PHPExcel_RichText_ITextElement
|
||||
foreach ($this->_richTextElements as $text) {
|
||||
$returnValue .= $text->getText();
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
*
|
||||
* @return PHPExcel_RichText_ITextElement[]
|
||||
*/
|
||||
public function getRichTextElements()
|
||||
{
|
||||
return $this->_richTextElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
*
|
||||
* @param PHPExcel_RichText_ITextElement[] $pElements Array of elements
|
||||
* @throws Exception
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function setRichTextElements($pElements = null)
|
||||
{
|
||||
if (is_array($pElements)) {
|
||||
$this->_richTextElements = $pElements;
|
||||
} else {
|
||||
throw new Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$hashElements = '';
|
||||
foreach ($this->_richTextElements as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5(
|
||||
$hashElements
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_ITextElement
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
public function setText($pText = '');
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
public function getFont();
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_Run
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var PHPExcel_Style_Font
|
||||
*/
|
||||
private $_font;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText_Run instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->setText($pText);
|
||||
$this->_font = new PHPExcel_Style_Font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return $this->_font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param PHPExcel_Style_Font $pFont Font
|
||||
* @throws Exception
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
public function setFont(PHPExcel_Style_Font $pFont = null) {
|
||||
$this->_font = $pFont;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->getText()
|
||||
. $this->_font->getHashCode()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_TextElement
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
{
|
||||
/**
|
||||
* Text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText_TextElement instance
|
||||
*
|
||||
* @param string $pText Text
|
||||
*/
|
||||
public function __construct($pText = '')
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_text = $pText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
public function setText($pText = '') {
|
||||
$this->_text = $pText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
public function getFont() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_text
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Settings
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
class PHPExcel_Settings
|
||||
{
|
||||
/** constants */
|
||||
/** Available Zip library classes */
|
||||
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
|
||||
const ZIPARCHIVE = 'ZipArchive';
|
||||
|
||||
/** Optional Chart Rendering libraries */
|
||||
const CHART_RENDERER_JPGRAPH = 'jpgraph';
|
||||
|
||||
/** Optional PDF Rendering libraries */
|
||||
const PDF_RENDERER_TCPDF = 'tcPDF';
|
||||
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
||||
const PDF_RENDERER_MPDF = 'mPDF';
|
||||
|
||||
|
||||
private static $_chartRenderers = array(
|
||||
self::CHART_RENDERER_JPGRAPH,
|
||||
);
|
||||
|
||||
private static $_pdfRenderers = array(
|
||||
self::PDF_RENDERER_TCPDF,
|
||||
self::PDF_RENDERER_DOMPDF,
|
||||
self::PDF_RENDERER_MPDF,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Name of the class used for Zip file management
|
||||
* e.g.
|
||||
* ZipArchive
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_zipClass = self::ZIPARCHIVE;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering charts
|
||||
* e.g.
|
||||
* jpgraph
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_chartRendererName = NULL;
|
||||
|
||||
/**
|
||||
* Directory Path to the external Library used for rendering charts
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_chartRendererPath = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering PDF files
|
||||
* e.g.
|
||||
* mPDF
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_pdfRendererName = NULL;
|
||||
|
||||
/**
|
||||
* Directory Path to the external Library used for rendering PDF files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_pdfRendererPath = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
|
||||
*
|
||||
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
|
||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setZipClass($zipClass) {
|
||||
if (($zipClass === self::PCLZIP) ||
|
||||
($zipClass === self::ZIPARCHIVE)) {
|
||||
self::$_zipClass = $zipClass;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
} // function setZipClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
|
||||
* for Zip file management
|
||||
*
|
||||
* @return string Name of the Zip handler Class that PHPExcel is configured to use
|
||||
* for Zip file management
|
||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||
*/
|
||||
public static function getZipClass() {
|
||||
return self::$_zipClass;
|
||||
} // function getZipClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the method that is currently configured for cell cacheing
|
||||
*
|
||||
* @return string Name of the cacheing method
|
||||
*/
|
||||
public static function getCacheStorageMethod() {
|
||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the class that is currently being used for cell cacheing
|
||||
*
|
||||
* @return string Name of the class currently being used for cacheing
|
||||
*/
|
||||
public static function getCacheStorageClass() {
|
||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
/**
|
||||
* Set the method that should be used for cell cacheing
|
||||
*
|
||||
* @param string $method Name of the cacheing method
|
||||
* @param array $arguments Optional configuration arguments for the cacheing method
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
|
||||
$arguments = array()) {
|
||||
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
|
||||
} // function setCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Set the locale code to use for formula translations and any special formatting
|
||||
*
|
||||
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setLocale($locale='en_us') {
|
||||
return PHPExcel_Calculation::getInstance()->setLocale($locale);
|
||||
} // function setLocale()
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PHPExcel should use for rendering charts
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRenderer($libraryName, $libraryBaseDir) {
|
||||
if (!self::setChartRendererName($libraryName))
|
||||
return FALSE;
|
||||
return self::setChartRendererPath($libraryBaseDir);
|
||||
} // function setChartRenderer()
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PHPExcel the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRendererName($libraryName) {
|
||||
if (!in_array($libraryName,self::$_chartRenderers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_chartRendererName = $libraryName;
|
||||
|
||||
return TRUE;
|
||||
} // function setChartRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Tell PHPExcel where to find the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRendererPath($libraryBaseDir) {
|
||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||
return FALSE;
|
||||
}
|
||||
self::$_chartRendererPath = $libraryBaseDir;
|
||||
|
||||
return TRUE;
|
||||
} // function setChartRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
*/
|
||||
public static function getChartRendererName() {
|
||||
return self::$_chartRendererName;
|
||||
} // function getChartRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getChartRendererPath() {
|
||||
return self::$_chartRendererPath;
|
||||
} // function getChartRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PHPExcel should use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRenderer($libraryName, $libraryBaseDir) {
|
||||
if (!self::setPdfRendererName($libraryName))
|
||||
return FALSE;
|
||||
return self::setPdfRendererPath($libraryBaseDir);
|
||||
} // function setPdfRenderer()
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PHPExcel the external library to use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRendererName($libraryName) {
|
||||
if (!in_array($libraryName,self::$_pdfRenderers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_pdfRendererName = $libraryName;
|
||||
|
||||
return TRUE;
|
||||
} // function setPdfRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Tell PHPExcel where to find the external library to use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRendererPath($libraryBaseDir) {
|
||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||
return FALSE;
|
||||
}
|
||||
self::$_pdfRendererPath = $libraryBaseDir;
|
||||
|
||||
return TRUE;
|
||||
} // function setPdfRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
*/
|
||||
public static function getPdfRendererName() {
|
||||
return self::$_pdfRendererName;
|
||||
} // function getPdfRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getPdfRendererPath() {
|
||||
return self::$_pdfRendererPath;
|
||||
} // function getPdfRendererPath()
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_CodePage
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_CodePage
|
||||
{
|
||||
/**
|
||||
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
||||
* and mbstring understands
|
||||
*
|
||||
* @param integer $codePage Microsoft Code Page Indentifier
|
||||
* @return string Code Page Name
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function NumberToName($codePage = 1252)
|
||||
{
|
||||
switch ($codePage) {
|
||||
case 367: return 'ASCII'; break; // ASCII
|
||||
case 437: return 'CP437'; break; // OEM US
|
||||
case 720: throw new Exception('Code page 720 not supported.');
|
||||
break; // OEM Arabic
|
||||
case 737: return 'CP737'; break; // OEM Greek
|
||||
case 775: return 'CP775'; break; // OEM Baltic
|
||||
case 850: return 'CP850'; break; // OEM Latin I
|
||||
case 852: return 'CP852'; break; // OEM Latin II (Central European)
|
||||
case 855: return 'CP855'; break; // OEM Cyrillic
|
||||
case 857: return 'CP857'; break; // OEM Turkish
|
||||
case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro
|
||||
case 860: return 'CP860'; break; // OEM Portugese
|
||||
case 861: return 'CP861'; break; // OEM Icelandic
|
||||
case 862: return 'CP862'; break; // OEM Hebrew
|
||||
case 863: return 'CP863'; break; // OEM Canadian (French)
|
||||
case 864: return 'CP864'; break; // OEM Arabic
|
||||
case 865: return 'CP865'; break; // OEM Nordic
|
||||
case 866: return 'CP866'; break; // OEM Cyrillic (Russian)
|
||||
case 869: return 'CP869'; break; // OEM Greek (Modern)
|
||||
case 874: return 'CP874'; break; // ANSI Thai
|
||||
case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS
|
||||
case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK
|
||||
case 949: return 'CP949'; break; // ANSI Korean (Wansung)
|
||||
case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5
|
||||
case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8)
|
||||
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
|
||||
case 1251: return 'CP1251'; break; // ANSI Cyrillic
|
||||
case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
|
||||
case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7)
|
||||
case 1253: return 'CP1253'; break; // ANSI Greek
|
||||
case 1254: return 'CP1254'; break; // ANSI Turkish
|
||||
case 1255: return 'CP1255'; break; // ANSI Hebrew
|
||||
case 1256: return 'CP1256'; break; // ANSI Arabic
|
||||
case 1257: return 'CP1257'; break; // ANSI Baltic
|
||||
case 1258: return 'CP1258'; break; // ANSI Vietnamese
|
||||
case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
|
||||
case 10000: return 'MAC'; break; // Apple Roman
|
||||
case 10006: return 'MACGREEK'; break; // Macintosh Greek
|
||||
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
|
||||
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
|
||||
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
|
||||
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
|
||||
case 32768: return 'MAC'; break; // Apple Roman
|
||||
case 32769: throw new Exception('Code page 32769 not supported.');
|
||||
break; // ANSI Latin I (BIFF2-BIFF3)
|
||||
case 65000: return 'UTF-7'; break; // Unicode (UTF-7)
|
||||
case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
|
||||
}
|
||||
|
||||
throw new Exception('Unknown codepage: ' . $codePage);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,358 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Date
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Date
|
||||
{
|
||||
/** constants */
|
||||
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
|
||||
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
|
||||
|
||||
/*
|
||||
* Names of the months of the year, indexed by shortname
|
||||
* Planned usage for locale settings
|
||||
*
|
||||
* @public
|
||||
* @var string[]
|
||||
*/
|
||||
public static $_monthNames = array( 'Jan' => 'January',
|
||||
'Feb' => 'February',
|
||||
'Mar' => 'March',
|
||||
'Apr' => 'April',
|
||||
'May' => 'May',
|
||||
'Jun' => 'June',
|
||||
'Jul' => 'July',
|
||||
'Aug' => 'August',
|
||||
'Sep' => 'September',
|
||||
'Oct' => 'October',
|
||||
'Nov' => 'November',
|
||||
'Dec' => 'December'
|
||||
);
|
||||
|
||||
/*
|
||||
* Base calendar year to use for calculations
|
||||
*
|
||||
* @private
|
||||
* @var int
|
||||
*/
|
||||
protected static $_excelBaseDate = self::CALENDAR_WINDOWS_1900;
|
||||
|
||||
/**
|
||||
* Set the Excel calendar (Windows 1900 or Mac 1904)
|
||||
*
|
||||
* @param integer $baseDate Excel base date (1900 or 1904)
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setExcelCalendar($baseDate) {
|
||||
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
|
||||
($baseDate == self::CALENDAR_MAC_1904)) {
|
||||
self::$_excelBaseDate = $baseDate;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
} // function setExcelCalendar()
|
||||
|
||||
|
||||
/**
|
||||
* Return the Excel calendar (Windows 1900 or Mac 1904)
|
||||
*
|
||||
* @return integer Excel base date (1900 or 1904)
|
||||
*/
|
||||
public static function getExcelCalendar() {
|
||||
return self::$_excelBaseDate;
|
||||
} // function getExcelCalendar()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date from Excel to PHP
|
||||
*
|
||||
* @param long $dateValue Excel date/time value
|
||||
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
||||
* a UST timestamp, or adjusted to UST
|
||||
* @param string $timezone The timezone for finding the adjustment from UST
|
||||
* @return long PHP serialized date/time
|
||||
*/
|
||||
public static function ExcelToPHP($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
|
||||
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
|
||||
$my_excelBaseDate = 25569;
|
||||
// Adjust for the spurious 29-Feb-1900 (Day 60)
|
||||
if ($dateValue < 60) {
|
||||
--$my_excelBaseDate;
|
||||
}
|
||||
} else {
|
||||
$my_excelBaseDate = 24107;
|
||||
}
|
||||
|
||||
// Perform conversion
|
||||
if ($dateValue >= 1) {
|
||||
$utcDays = $dateValue - $my_excelBaseDate;
|
||||
$returnValue = round($utcDays * 86400);
|
||||
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
|
||||
$returnValue = (integer) $returnValue;
|
||||
}
|
||||
} else {
|
||||
$hours = round($dateValue * 24);
|
||||
$mins = round($dateValue * 1440) - round($hours * 60);
|
||||
$secs = round($dateValue * 86400) - round($hours * 3600) - round($mins * 60);
|
||||
$returnValue = (integer) gmmktime($hours, $mins, $secs);
|
||||
}
|
||||
|
||||
$timezoneAdjustment = ($adjustToTimezone) ?
|
||||
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone, $returnValue) :
|
||||
0;
|
||||
|
||||
// Return
|
||||
return $returnValue + $timezoneAdjustment;
|
||||
} // function ExcelToPHP()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date from Excel to a PHP Date/Time object
|
||||
*
|
||||
* @param integer $dateValue Excel date/time value
|
||||
* @return integer PHP date/time object
|
||||
*/
|
||||
public static function ExcelToPHPObject($dateValue = 0) {
|
||||
$dateTime = self::ExcelToPHP($dateValue);
|
||||
$days = floor($dateTime / 86400);
|
||||
$time = round((($dateTime / 86400) - $days) * 86400);
|
||||
$hours = round($time / 3600);
|
||||
$minutes = round($time / 60) - ($hours * 60);
|
||||
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
|
||||
|
||||
$dateObj = date_create('1-Jan-1970+'.$days.' days');
|
||||
$dateObj->setTime($hours,$minutes,$seconds);
|
||||
|
||||
return $dateObj;
|
||||
} // function ExcelToPHPObject()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date from PHP to Excel
|
||||
*
|
||||
* @param mixed $dateValue PHP serialized date/time or date object
|
||||
* @param boolean $adjustToTimezone Flag indicating whether $dateValue should be treated as
|
||||
* a UST timestamp, or adjusted to UST
|
||||
* @param string $timezone The timezone for finding the adjustment from UST
|
||||
* @return mixed Excel date/time value
|
||||
* or boolean FALSE on failure
|
||||
*/
|
||||
public static function PHPToExcel($dateValue = 0, $adjustToTimezone = FALSE, $timezone = NULL) {
|
||||
$saveTimeZone = date_default_timezone_get();
|
||||
date_default_timezone_set('UTC');
|
||||
$retValue = FALSE;
|
||||
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
|
||||
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
|
||||
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
|
||||
);
|
||||
} elseif (is_numeric($dateValue)) {
|
||||
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue),
|
||||
date('H',$dateValue), date('i',$dateValue), date('s',$dateValue)
|
||||
);
|
||||
}
|
||||
date_default_timezone_set($saveTimeZone);
|
||||
|
||||
return $retValue;
|
||||
} // function PHPToExcel()
|
||||
|
||||
|
||||
/**
|
||||
* FormattedPHPToExcel
|
||||
*
|
||||
* @param long $year
|
||||
* @param long $month
|
||||
* @param long $day
|
||||
* @param long $hours
|
||||
* @param long $minutes
|
||||
* @param long $seconds
|
||||
* @return long Excel date/time value
|
||||
*/
|
||||
public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) {
|
||||
if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {
|
||||
//
|
||||
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
|
||||
// This affects every date following 28th February 1900
|
||||
//
|
||||
$excel1900isLeapYear = TRUE;
|
||||
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = FALSE; }
|
||||
$my_excelBaseDate = 2415020;
|
||||
} else {
|
||||
$my_excelBaseDate = 2416481;
|
||||
$excel1900isLeapYear = FALSE;
|
||||
}
|
||||
|
||||
// Julian base date Adjustment
|
||||
if ($month > 2) {
|
||||
$month -= 3;
|
||||
} else {
|
||||
$month += 9;
|
||||
--$year;
|
||||
}
|
||||
|
||||
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
|
||||
$century = substr($year,0,2);
|
||||
$decade = substr($year,2,2);
|
||||
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $my_excelBaseDate + $excel1900isLeapYear;
|
||||
|
||||
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
|
||||
|
||||
return (float) $excelDate + $excelTime;
|
||||
} // function FormattedPHPToExcel()
|
||||
|
||||
|
||||
/**
|
||||
* Is a given cell a date/time?
|
||||
*
|
||||
* @param PHPExcel_Cell $pCell
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDateTime(PHPExcel_Cell $pCell) {
|
||||
return self::isDateTimeFormat(
|
||||
$pCell->getParent()->getStyle(
|
||||
$pCell->getCoordinate()
|
||||
)->getNumberFormat()
|
||||
);
|
||||
} // function isDateTime()
|
||||
|
||||
|
||||
/**
|
||||
* Is a given number format a date/time?
|
||||
*
|
||||
* @param PHPExcel_Style_NumberFormat $pFormat
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) {
|
||||
return self::isDateTimeFormatCode($pFormat->getFormatCode());
|
||||
} // function isDateTimeFormat()
|
||||
|
||||
|
||||
private static $possibleDateFormatCharacters = 'eymdHs';
|
||||
|
||||
/**
|
||||
* Is a given number format code a date/time?
|
||||
*
|
||||
* @param string $pFormatCode
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDateTimeFormatCode($pFormatCode = '') {
|
||||
// Switch on formatcode
|
||||
switch ($pFormatCode) {
|
||||
// General contains an epoch letter 'e', so we trap for it explicitly here
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_GENERAL:
|
||||
return FALSE;
|
||||
// Explicitly defined date formats
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
|
||||
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Typically number, currency or accounting (or occasionally fraction) formats
|
||||
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
|
||||
return FALSE;
|
||||
}
|
||||
// Try checking for any of the date formatting characters that don't appear within square braces
|
||||
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
|
||||
// We might also have a format mask containing quoted strings...
|
||||
// we don't want to test for any of our characters within the quoted blocks
|
||||
if (strpos($pFormatCode,'"') !== FALSE) {
|
||||
$segMatcher = FALSE;
|
||||
foreach(explode('"',$pFormatCode) as $subVal) {
|
||||
// Only test in alternate array entries (the non-quoted blocks)
|
||||
if (($segMatcher = !$segMatcher) &&
|
||||
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// No date...
|
||||
return FALSE;
|
||||
} // function isDateTimeFormatCode()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date/time string to Excel time
|
||||
*
|
||||
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
|
||||
* @return float|FALSE Excel date/time serial value
|
||||
*/
|
||||
public static function stringToExcel($dateValue = '') {
|
||||
if (strlen($dateValue) < 2)
|
||||
return FALSE;
|
||||
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue))
|
||||
return FALSE;
|
||||
|
||||
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
|
||||
|
||||
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
|
||||
return FALSE;
|
||||
} else {
|
||||
if (strpos($dateValue, ':') !== FALSE) {
|
||||
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
|
||||
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
|
||||
return FALSE;
|
||||
}
|
||||
$dateValueNew += $timeValue;
|
||||
}
|
||||
return $dateValueNew;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,272 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Drawing
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Drawing
|
||||
{
|
||||
/**
|
||||
* Convert pixels to EMU
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in EMU
|
||||
*/
|
||||
public static function pixelsToEMU($pValue = 0) {
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
* @param int $pValue Value in EMU
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function EMUToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 9525);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to column width. Exact algorithm not known.
|
||||
* By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
|
||||
* This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in cell dimension
|
||||
*/
|
||||
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * 11
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
|
||||
}
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert column width from (intrinsic) Excel units to pixels
|
||||
*
|
||||
* @param float $pValue Value in cell dimension
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
|
||||
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * $size
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
|
||||
}
|
||||
|
||||
// Round pixels to closest integer
|
||||
$colWidth = (int) round($colWidth);
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @return int Value in points
|
||||
*/
|
||||
public static function pixelsToPoints($pValue = 0) {
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert points to pixels
|
||||
*
|
||||
* @param int $pValue Value in points
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function pointsToPixels($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return (int) ceil($pValue * 1.333333333);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert degrees to angle
|
||||
*
|
||||
* @param int $pValue Degrees
|
||||
* @return int Angle
|
||||
*/
|
||||
public static function degreesToAngle($pValue = 0) {
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
* @param int $pValue Angle
|
||||
* @return int Degrees
|
||||
*/
|
||||
public static function angleToDegrees($pValue = 0) {
|
||||
if ($pValue != 0) {
|
||||
return round($pValue / 60000);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new image from file. By alexander at alexauto dot nl
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
|
||||
* @param string $filename Path to Windows DIB (BMP) image
|
||||
* @return resource
|
||||
*/
|
||||
public static function imagecreatefrombmp($p_sFile)
|
||||
{
|
||||
// Load the image into a string
|
||||
$file = fopen($p_sFile,"rb");
|
||||
$read = fread($file,10);
|
||||
while(!feof($file)&&($read<>""))
|
||||
$read .= fread($file,1024);
|
||||
|
||||
$temp = unpack("H*",$read);
|
||||
$hex = $temp[1];
|
||||
$header = substr($hex,0,108);
|
||||
|
||||
// Process the header
|
||||
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
|
||||
if (substr($header,0,4)=="424d")
|
||||
{
|
||||
// Cut it in parts of 2 bytes
|
||||
$header_parts = str_split($header,2);
|
||||
|
||||
// Get the width 4 bytes
|
||||
$width = hexdec($header_parts[19].$header_parts[18]);
|
||||
|
||||
// Get the height 4 bytes
|
||||
$height = hexdec($header_parts[23].$header_parts[22]);
|
||||
|
||||
// Unset the header params
|
||||
unset($header_parts);
|
||||
}
|
||||
|
||||
// Define starting X and Y
|
||||
$x = 0;
|
||||
$y = 1;
|
||||
|
||||
// Create newimage
|
||||
$image = imagecreatetruecolor($width,$height);
|
||||
|
||||
// Grab the body from the image
|
||||
$body = substr($hex,108);
|
||||
|
||||
// Calculate if padding at the end-line is needed
|
||||
// Divided by two to keep overview.
|
||||
// 1 byte = 2 HEX-chars
|
||||
$body_size = (strlen($body)/2);
|
||||
$header_size = ($width*$height);
|
||||
|
||||
// Use end-line padding? Only when needed
|
||||
$usePadding = ($body_size>($header_size*3)+4);
|
||||
|
||||
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
|
||||
// Calculate the next DWORD-position in the body
|
||||
for ($i=0;$i<$body_size;$i+=3)
|
||||
{
|
||||
// Calculate line-ending and padding
|
||||
if ($x>=$width)
|
||||
{
|
||||
// If padding needed, ignore image-padding
|
||||
// Shift i to the ending of the current 32-bit-block
|
||||
if ($usePadding)
|
||||
$i += $width%4;
|
||||
|
||||
// Reset horizontal position
|
||||
$x = 0;
|
||||
|
||||
// Raise the height-position (bottom-up)
|
||||
$y++;
|
||||
|
||||
// Reached the image-height? Break the for-loop
|
||||
if ($y>$height)
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculation of the RGB-pixel (defined as BGR in image-data)
|
||||
// Define $i_pos as absolute position in the body
|
||||
$i_pos = $i*2;
|
||||
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
|
||||
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
|
||||
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
|
||||
|
||||
// Calculate and draw the pixel
|
||||
$color = imagecolorallocate($image,$r,$g,$b);
|
||||
imagesetpixel($image,$x,$height-$y,$color);
|
||||
|
||||
// Raise the horizontal position
|
||||
$x++;
|
||||
}
|
||||
|
||||
// Unset the body / free the memory
|
||||
unset($body);
|
||||
|
||||
// Return image-object
|
||||
return $image;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher
|
||||
{
|
||||
/**
|
||||
* Drawing Group Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer
|
||||
*/
|
||||
private $_dggContainer;
|
||||
|
||||
/**
|
||||
* Drawing Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DgContainer
|
||||
*/
|
||||
private $_dgContainer;
|
||||
|
||||
/**
|
||||
* Get Drawing Group Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer
|
||||
*/
|
||||
public function getDggContainer()
|
||||
{
|
||||
return $this->_dggContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Drawing Group Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer $dggContainer
|
||||
*/
|
||||
public function setDggContainer($dggContainer)
|
||||
{
|
||||
return $this->_dggContainer = $dggContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Drawing Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer
|
||||
*/
|
||||
public function getDgContainer()
|
||||
{
|
||||
return $this->_dgContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Drawing Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DgContainer $dgContainer
|
||||
*/
|
||||
public function setDgContainer($dgContainer)
|
||||
{
|
||||
return $this->_dgContainer = $dgContainer;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DgContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer
|
||||
{
|
||||
/**
|
||||
* Drawing index, 1-based.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_dgId;
|
||||
|
||||
/**
|
||||
* Last shape index in this drawing
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_lastSpId;
|
||||
|
||||
private $_spgrContainer = null;
|
||||
|
||||
public function getDgId()
|
||||
{
|
||||
return $this->_dgId;
|
||||
}
|
||||
|
||||
public function setDgId($value)
|
||||
{
|
||||
$this->_dgId = $value;
|
||||
}
|
||||
|
||||
public function getLastSpId()
|
||||
{
|
||||
return $this->_lastSpId;
|
||||
}
|
||||
|
||||
public function setLastSpId($value)
|
||||
{
|
||||
$this->_lastSpId = $value;
|
||||
}
|
||||
|
||||
public function getSpgrContainer()
|
||||
{
|
||||
return $this->_spgrContainer;
|
||||
}
|
||||
|
||||
public function setSpgrContainer($spgrContainer)
|
||||
{
|
||||
return $this->_spgrContainer = $spgrContainer;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
{
|
||||
/**
|
||||
* Parent Shape Group Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Shape Container collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_children = array();
|
||||
|
||||
/**
|
||||
* Set parent Shape Group Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent Shape Group Container if any
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer|null
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child. This will be either spgrContainer or spContainer
|
||||
*
|
||||
* @param mixed $child
|
||||
*/
|
||||
public function addChild($child)
|
||||
{
|
||||
$this->_children[] = $child;
|
||||
$child->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of Shape Containers
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively get all spContainers within this spgrContainer
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer[]
|
||||
*/
|
||||
public function getAllSpContainers()
|
||||
{
|
||||
$allSpContainers = array();
|
||||
|
||||
foreach ($this->_children as $child) {
|
||||
if ($child instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) {
|
||||
$allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
|
||||
} else {
|
||||
$allSpContainers[] = $child;
|
||||
}
|
||||
}
|
||||
|
||||
return $allSpContainers;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,395 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
|
||||
{
|
||||
/**
|
||||
* Parent Shape Group Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Is this a group shape?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_spgr = false;
|
||||
|
||||
/**
|
||||
* Shape type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_spType;
|
||||
|
||||
/**
|
||||
* Shape flag
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_spFlag;
|
||||
|
||||
/**
|
||||
* Shape index (usually group shape has index 0, and the rest: 1,2,3...)
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_spId;
|
||||
|
||||
/**
|
||||
* Array of options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_OPT;
|
||||
|
||||
/**
|
||||
* Cell coordinates of upper-left corner of shape, e.g. 'A1'
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_startCoordinates;
|
||||
|
||||
/**
|
||||
* Horizontal offset of upper-left corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_startOffsetX;
|
||||
|
||||
/**
|
||||
* Vertical offset of upper-left corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_startOffsetY;
|
||||
|
||||
/**
|
||||
* Cell coordinates of bottom-right corner of shape, e.g. 'B2'
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_endCoordinates;
|
||||
|
||||
/**
|
||||
* Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_endOffsetX;
|
||||
|
||||
/**
|
||||
* Vertical offset of bottom-right corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_endOffsetY;
|
||||
|
||||
/**
|
||||
* Set parent Shape Group Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent Shape Group Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this is a group shape
|
||||
*
|
||||
* @param boolean $value
|
||||
*/
|
||||
public function setSpgr($value = false)
|
||||
{
|
||||
$this->_spgr = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this is a group shape
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getSpgr()
|
||||
{
|
||||
return $this->_spgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shape type
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setSpType($value)
|
||||
{
|
||||
$this->_spType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shape type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpType()
|
||||
{
|
||||
return $this->_spType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shape flag
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setSpFlag($value)
|
||||
{
|
||||
$this->_spFlag = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shape flag
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpFlag()
|
||||
{
|
||||
return $this->_spFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the shape index
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setSpId($value)
|
||||
{
|
||||
$this->_spId = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shape index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpId()
|
||||
{
|
||||
return $this->_spId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the Shape Group Container
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setOPT($property, $value)
|
||||
{
|
||||
$this->_OPT[$property] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option for the Shape Group Container
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOPT($property)
|
||||
{
|
||||
if (isset($this->_OPT[$property])) {
|
||||
return $this->_OPT[$property];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOPTCollection()
|
||||
{
|
||||
return $this->_OPT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell coordinates of upper-left corner of shape
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setStartCoordinates($value = 'A1')
|
||||
{
|
||||
$this->_startCoordinates = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell coordinates of upper-left corner of shape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStartCoordinates()
|
||||
{
|
||||
return $this->_startCoordinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in x-direction of upper-left corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @param int $startOffsetX
|
||||
*/
|
||||
public function setStartOffsetX($startOffsetX = 0)
|
||||
{
|
||||
$this->_startOffsetX = $startOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in x-direction of upper-left corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStartOffsetX()
|
||||
{
|
||||
return $this->_startOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in y-direction of upper-left corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @param int $startOffsetY
|
||||
*/
|
||||
public function setStartOffsetY($startOffsetY = 0)
|
||||
{
|
||||
$this->_startOffsetY = $startOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in y-direction of upper-left corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStartOffsetY()
|
||||
{
|
||||
return $this->_startOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell coordinates of bottom-right corner of shape
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setEndCoordinates($value = 'A1')
|
||||
{
|
||||
$this->_endCoordinates = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cell coordinates of bottom-right corner of shape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEndCoordinates()
|
||||
{
|
||||
return $this->_endCoordinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @param int $startOffsetX
|
||||
*/
|
||||
public function setEndOffsetX($endOffsetX = 0)
|
||||
{
|
||||
$this->_endOffsetX = $endOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEndOffsetX()
|
||||
{
|
||||
return $this->_endOffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set offset in y-direction of bottom-right corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @param int $endOffsetY
|
||||
*/
|
||||
public function setEndOffsetY($endOffsetY = 0)
|
||||
{
|
||||
$this->_endOffsetY = $endOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offset in y-direction of bottom-right corner of shape measured in 1/256 of row height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEndOffsetY()
|
||||
{
|
||||
return $this->_endOffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nesting level of this spContainer. This is the number of spgrContainers between this spContainer and
|
||||
* the dgContainer. A value of 1 = immediately within first spgrContainer
|
||||
* Higher nesting level occurs if and only if spContainer is part of a shape group
|
||||
*
|
||||
* @return int Nesting level
|
||||
*/
|
||||
public function getNestingLevel()
|
||||
{
|
||||
$nestingLevel = 0;
|
||||
|
||||
$parent = $this->getParent();
|
||||
while ($parent instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) {
|
||||
++$nestingLevel;
|
||||
$parent = $parent->getParent();
|
||||
}
|
||||
|
||||
return $nestingLevel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer
|
||||
{
|
||||
/**
|
||||
* Maximum shape index of all shapes in all drawings increased by one
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_spIdMax;
|
||||
|
||||
/**
|
||||
* Total number of drawings saved
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cDgSaved;
|
||||
|
||||
/**
|
||||
* Total number of shapes saved (including group shapes)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cSpSaved;
|
||||
|
||||
/**
|
||||
* BLIP Store Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*/
|
||||
private $_bstoreContainer;
|
||||
|
||||
/**
|
||||
* Array of options for the drawing group
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_OPT = array();
|
||||
|
||||
/**
|
||||
* Array of identifier clusters containg information about the maximum shape identifiers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_IDCLs = array();
|
||||
|
||||
/**
|
||||
* Get maximum shape index of all shapes in all drawings (plus one)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSpIdMax()
|
||||
{
|
||||
return $this->_spIdMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set maximum shape index of all shapes in all drawings (plus one)
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setSpIdMax($value)
|
||||
{
|
||||
$this->_spIdMax = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total number of drawings saved
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCDgSaved()
|
||||
{
|
||||
return $this->_cDgSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set total number of drawings saved
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setCDgSaved($value)
|
||||
{
|
||||
$this->_cDgSaved = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total number of shapes saved (including group shapes)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCSpSaved()
|
||||
{
|
||||
return $this->_cSpSaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set total number of shapes saved (including group shapes)
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setCSpSaved($value)
|
||||
{
|
||||
$this->_cSpSaved = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BLIP Store Container
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*/
|
||||
public function getBstoreContainer()
|
||||
{
|
||||
return $this->_bstoreContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set BLIP Store Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $bstoreContainer
|
||||
*/
|
||||
public function setBstoreContainer($bstoreContainer)
|
||||
{
|
||||
$this->_bstoreContainer = $bstoreContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the drawing group
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setOPT($property, $value)
|
||||
{
|
||||
$this->_OPT[$property] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option for the drawing group
|
||||
*
|
||||
* @param int $property The number specifies the option
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOPT($property)
|
||||
{
|
||||
if (isset($this->_OPT[$property])) {
|
||||
return $this->_OPT[$property];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier clusters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getIDCLs()
|
||||
{
|
||||
return $this->_IDCLs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set identifier clusters. array(<drawingId> => <max shape id>, ...)
|
||||
*
|
||||
* @param array $pValue
|
||||
*/
|
||||
public function setIDCLs($pValue)
|
||||
{
|
||||
$this->_IDCLs = $pValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
{
|
||||
/**
|
||||
* BLIP Store Entries. Each of them holds one BLIP (Big Large Image or Picture)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_BSECollection = array();
|
||||
|
||||
/**
|
||||
* Add a BLIP Store Entry
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $BSE
|
||||
*/
|
||||
public function addBSE($BSE)
|
||||
{
|
||||
$this->_BSECollection[] = $BSE;
|
||||
$BSE->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the collection of BLIP Store Entries
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE[]
|
||||
*/
|
||||
public function getBSECollection()
|
||||
{
|
||||
return $this->_BSECollection;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
|
||||
{
|
||||
const BLIPTYPE_ERROR = 0x00;
|
||||
const BLIPTYPE_UNKNOWN = 0x01;
|
||||
const BLIPTYPE_EMF = 0x02;
|
||||
const BLIPTYPE_WMF = 0x03;
|
||||
const BLIPTYPE_PICT = 0x04;
|
||||
const BLIPTYPE_JPEG = 0x05;
|
||||
const BLIPTYPE_PNG = 0x06;
|
||||
const BLIPTYPE_DIB = 0x07;
|
||||
const BLIPTYPE_TIFF = 0x11;
|
||||
const BLIPTYPE_CMYKJPEG = 0x12;
|
||||
|
||||
/**
|
||||
* The parent BLIP Store Entry Container
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* The BLIP (Big Large Image or Picture)
|
||||
*
|
||||
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
*/
|
||||
private $_blip;
|
||||
|
||||
/**
|
||||
* The BLIP type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_blipType;
|
||||
|
||||
/**
|
||||
* Set parent BLIP Store Entry Container
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $parent
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BLIP
|
||||
*
|
||||
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
*/
|
||||
public function getBlip()
|
||||
{
|
||||
return $this->_blip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BLIP
|
||||
*
|
||||
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip $blip
|
||||
*/
|
||||
public function setBlip($blip)
|
||||
{
|
||||
$this->_blip = $blip;
|
||||
$blip->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BLIP type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlipType()
|
||||
{
|
||||
return $this->_blipType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BLIP type
|
||||
*
|
||||
* @param int
|
||||
*/
|
||||
public function setBlipType($blipType)
|
||||
{
|
||||
$this->_blipType = $blipType;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue