I'm trying to format cell in my xls output sheet but when I'm trying to use
$xls->getActiveSheet()->getStyle('A1')->getFont()->getColor()->setRGB(PHPExcel_Style_Color::COLOR_WHITE);
or any other method with getStyle() I'm getting this error:
( ! ) Fatal error: Call to a member function getNumberFormat() on a non-object in "..."/Worksheet.php in line 755
Other getActiveSheet() methods like setTitle() or getColumnDimension() are working fine. I'm using Excel5 writer, but when I tried Excel2007 I got the same error. Anyone know what might be the problem? Thanks in advance.
When I comment out the column width loop I don't get the error, but the style applying still doesn't work. Column width loop works perfectly without style applying code.
You can try this method to add style to your PHPExcel.
First create a array with the styles.
Something like this
$color = array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb' => 'A5A5A5')
),
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
)
);
After creating the array you have to apply the styles to your object.
Something like this.
$xls->getActiveSheet()->getStyle('A1:A10')->applyFromArray($color);
Related
Add an extra field for fileupload. But the data getting in template is a set of special characters. How to get the original path?
My code:
$GLOBALS['TL_DCA']['tl_news']['fields']['image'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_news']['quoteperson_image'],
'exclude' => true,
'filter' => true,
'inputType' => 'fileTree',
'eval' => array('tl_class' => 'clr','files' => true,'fieldType' =>'checkbox',),
'sql' => "blob NULL",
);
The data returned by the fileTree widget is a binary UUID. In order to get the original path you can do the following for example:
$objFile = \Contao\FilesModel::findByUuid($uuid);
$strPath = $objFile->path;
I'm adding new icons to the Visual Composer iconbox in wordpress but i get the following 2 errors anyone know how to fix? Below is the code in my functions.php file
// Add new custom font to Font Family selection in icon box module
function myprefix_add_new_icon_set_to_iconbox( ) {
$param = WPBMap::getParam( 'vcex_icon_box', 'icon_type' );
$param['value'][__( 'CUSTOM ICONS NAME', 'total' )] = 'my_custom_icons';
vc_update_shortcode_param( 'vcex_icon_box', $param );
}
add_filter( 'init', 'myprefix_add_new_icon_set_to_iconbox', 40 );
// Add font picker setting to icon box module when you select your font family from the dropdown
function myprefix_add_font_picker() {
vc_add_param( 'vcex_icon_box', array(
'type' => 'iconpicker',
'heading' => esc_html__( 'Icon', 'total' ),
'param_name' => 'my_custom_icons',
'settings' => array(
'emptyIcon' => true,
'type' => 'my_custom_icons',
'iconsPerPage' => 20,
),
'dependency' => array(
'element' => 'icon_type',
'value' => 'my_custom_icons',
),
'group' => esc_html__( 'Icon', 'total' ),
)
);
}
add_filter( 'vc_after_init', 'myprefix_add_font_picker', 40 );
// Add array of your fonts so they can be displayed in the font selector
function my_icon_array() {
return array(
array(
'bg-icon-twitter' => 'Twitter',
'bg-icon-user' => 'User'
));
}
add_filter( 'vc_iconpicker-type-my_custom_icons', 'my_icon_array' );
Notice:
Wrong name for shortcode:vcex_icon_box. Name required in
/home/.../plugins/js_composer/include/classes/core/class-wpb-map.php
on line 472
Warning:
Cannot use a scalar value as an array in
/home/.../plugins/js_composer/include/classes/core/class-wpb-map.php
on line 367
Error 1 is caused by the fact you don't have a shortcode in your installation called "vcex_icon_box". Try "vc_icon" instead.
Also, if you use vc_icon, you will need to change the dependency element to type and not icon_type.
For error 2, WPBMap::getParam( 'vcex_icon_box', 'icon_type' ); is returning a scalar value, which you can then treat it like an array.
As a debug tip, its a good idea to test the outputs of functions so you understand what you are getting.
The VC documentation is also not the greatest.
I am trying to set background color of a call based on cell value, But i am getting error when i use the below code
function bgColor($cell,$color){
global $F;
$F->getStyle($cell)->applyFromArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'startcolor' => array('rgb' => $color),
'endcolor' => array('rgb' => $color)
//'color' => array('argb' => $color)
)
)
);
}
if i use rgb the following error occurs
Repaired Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 2, column 934.
Removed Feature: Format from /xl/styles.xml part (Styles)
Removed Records: Style from /xl/styles.xml part (Styles)
if i use argb the first cell is filled with black color, while the argument passed to the color is yellow.
Ca anyone please tell me what i am doing wrong here
How can one change the order on each subpanel either by code or through the GUI?
In Sugar 6 the user could change the order simply by dragging and dropping the subpanels under each module.
From what I can see this is not possible in 7.x.
I have tried to change
'order' => 1
in
custom/Extension/modules/Opportunities/Ext/Layoutdefs/some_file.php
with no luck at all..
UPDATE:
As UTAlan stated,
this will become part of the stock functionality of Sugar starting in version 7.5.0: https://web.sugarcrm.com/support/issues/66590
Until then, here is the reason and the solution:
The 'order' => 1, does not seem to work on Sugar 7 at the moment.
Solution
Copy the file
modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
to
custom/modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
Now, add your custom subpanel definition to the beginning of the array or in any order you desire.
My example looks like this now:
$viewdefs['Opportunities']['base']['layout']['subpanels'] = array(
'components' => array(
// This is my custom module
array(
'layout' => 'subpanel',
'label' => 'LBL_OPPORTUNITIES_FOOBAR_TITLE',
'context' => array(
'link' => 'opportunities_foobar_1',
),
),
.. // Code ommited
array(
'layout' => 'subpanel',
'label' => 'LBL_EMAILS_SUBPANEL_TITLE',
'context' => array (
'link' => 'archived_emails',
),
),
),
'type' => 'subpanels',
'span' => 12,
);
Long Answer:
Why is 'order' => 1 not working anymore?
Inside include/MetaDataManager/MetaDataConverter.php:327:
public function toLegacySubpanelLayoutDefs(array $layoutDefs, SugarBean $bean) {
..
foreach ($layoutDefs as $order => $def) {
..
$return[$def['context']['link']] = array(
'order' => $order,
..
}
The order that is being rendered in the view is based on which order each bean-name is inserted inside the 'components'-key inside this file:
modules/Opportunities/clients/base/layouts/subpanels/subpanels.php
Core modules are hard-coded inside the subpanel file for Opportunities.
This will become part of the stock functionality of Sugar starting in version 7.5.0: https://web.sugarcrm.com/support/issues/66590
I have an array of models that looks something like this. The models are extensions of the base Yii model class (BazClass), so that's a little bit of a custom solution, but I don't see why it shouldn't work.
$list = array
(
0 => FooClass#1
(
[BazClass:_attributes] => array
(
'FOO_ATTRIBUTE' => '4567'
'BAZ_ATTRIBUTE' => '1234'
'NAME' => 'FOO BAR'
)
[BazClass:_related] => array()
[_md] => null
[CModel:_errors] => array()
[CModel:_validators] => null
[CModel:_scenario] => ''
[CComponent:_e] => null
[CComponent:_m] => null
),
)
I made this a data provider by doing so:
$dataProvider = new CArrayDataProvider($list, array(
'pagination'=>array(
'pageSize'=>10,
),
));
$dataProvider->setData($list);
And try to render it in the view like so. Basically I'm just trying to show a list of the names, with the column named "Name".
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'header' => 'Name',
'value' => $data->NAME,
),
),
));
The examples in the CGridView documentation make it look like that is possible, but the error I get is:
Either "name" or "value" must be specified for CDataColumn.
Well, I did specify a value, obviously, but it seems to be null. I also tried $data['NAME'] (because I somewhere read that the CArrayDataProvider doesn't return models), but it still evaluates to null.
I also checked that $dataProvider->getData() returns the same list as I passed it.
What gives?
you should place quotes around your value otherwise it gets interpreted in the wrong context
array( 'header' => 'Name', 'value' => '$data->NAME', ),