I'm using the PHPExcel to generate some sheets on my server. More or less it everything works fine, but, when I try to color some rows (every second row, so the list would be easily readable) I get funny thing: the row is colored ok, but only on cells that are not filled with data. The cells that are filled with data remain white.
Here's code I use
$ind = ($ind + 1) % 2;
if($ind == 1)
{
$style_header = array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb'=>'CCC'),
),
'font' => array(
'bold' => true,
)
);
$sheet->getStyle($row)->applyFromArray( $style_header );
}
$sheet->getCellByColumnAndRow(0, $row)->setValue($item['qty']);
$sheet->getCellByColumnAndRow(1, $row)->setValueExplicit($item['name']);
$sheet->getCellByColumnAndRow(2, $row)->setValueExplicit($item['size']);
$sheet->getCellByColumnAndRow(3, $row)->setValueExplicit($item['color']);
What am I doing wrong?
I don't see anything that jumps out at me as being wrong. Does the bold font get applied to the cells with text or is the entire style being ignored? If the bold does get set, try flipping the order of 'fill' and 'font' within the array. I wouldn't think that should make a difference, though.
You could also try $sheet->getStyle('A$row:D$row')->... as well, just to explicitly set the style for the range of cells you're using instead of the whole row.
here you can get good examples
http://bayu.freelancer.web.id/2010/07/16/phpexcel-advanced-read-write-excel-made-simple/
Related
I am trying to get my text to wrap around and display in multiple lines in Office UI Fabric's DetailsRow. At the moment some of my rows that have long text go off the screen, and I would like them to wrap around so the user does not have to scroll to read the entire row.
This is my GroupedList
<GroupedList
items={this._items}
onRenderCell={this._onRenderCell}
groups={this._groups}
selectionMode={SelectionMode.none}
compact={true}
/>
This is my render method for each cell.
_onRenderCell = (nestingDepth, item, itemIndex) => {
return (
<DetailsRow
columns={this._columns}
groupNestingDepth={nestingDepth}
item={item}
itemIndex={itemIndex}
selection={this._selection}
selectionMode={SelectionMode.none}
onClick={() => this.insertComment(item.key, item.link)}
/>
);
};
Any ideas on how to make the text wrap? I am a beginner when it comes to styling.
If you have specific columns whose text are known to require more than "1 line" of text, you can use the isMultiLine property on the column. This is the example that sets isMultiLine to true for a column to wrap the text, which in turn enlarges the height of the corresponding row: "DetailsList - Variable Row Heights".
I have color settings as acf options page set as follows.
Color Settings:
Field Type : Repeater
Fields: color name and color value(e.g. orange => #FC7F34, blue => #14B1E7)
I am using this settings in my other custom fields as radio button.So when user choose button color it's saved as hex code(#FC7F34).
Now in front end I want both that color name and color value. I have tried below option but as we have multiple buttons I think this will effect the load time.
$data['colors'] = get_field( 'color_fields', 'option' );
foreach($data['colors'] as $color) {
$data[$color['color_value']] = $color['color_name'];
}
Result:
[#FC7F34] => Orange
[#14B1E7] => Blue
[#007DC5] => Dark Blue
Is there any other effective way to show Orange when we have #FC7F34 chosen as button color.
Any help/suggestions are welcome.
Yes it's possible using if else condition otherwise not possible because if you find on google orange code hex code then it showing different . now it's only possible from if condition .
if your color code is fix then one solution
if($data[$color['color_value']]=='#FC7F34') { echo 'orange';}
I have a grid which is declared with column widths. basically like this:
#(Html.Kendo().Grid<TelerikMvcApp1.Models.Product>()
.Name("acct_dtls")
.HtmlAttributes(new{style="width:100%", #class="panel-body"})
.DataSource(ds => ds.Ajax().Read("Read", "Home"))
.Pageable()
.Sortable()
.Columns(columns =>
{
columns.Bound(Agent => Agent.ProductID).Width(300).Encoded(false).Hidden(false).Groupable(false).IncludeInMenu(false).Sortable(false);
columns.Bound(Agent => Agent.ProductName).Width(100).Encoded(true).Hidden(false).Groupable(false).IncludeInMenu(true).Sortable(false);
})
.Reorderable(r => r.Columns(true))
.Resizable(r => r.Columns(true))
.ColumnResizeHandleWidth(5)
.ColumnMenu()
.Filterable()
.Scrollable()
)
the problem is when it is rendered, the browser automatically adjust the columns widths just like responsive rendering. i have tried setting the table-layout property to "fixed" but still no working. Thanks for those who will share their knowledge
The grid has the table-layout: fixed setting applied by default. The problem is that you have set the width of both columns to a value which is less than the total grid width. You should avoid setting the width of one of the columns so it can occupy the remaining space.
I've been playing with the animation package lately. Pretty nifty stuff but in the use of saveHTML I get a control panel with a green dot for every image (see below) and I have a ton of images. How can I make the green dots go away but keep the control panel?
I asked a related question yesterday so the minimal working example is there (my data set and mnel's answer).
Here's the code I'm using to make the html file:
saveHTML(pp(), autoplay=FALSE, loop=FALSE, verbose=FALSE, outdir = "new")
The animation help manual says see the reference for a complete list of available options but I can not figure out how to do what I've asked above.
You want to remove the 'navigator' option from 'controls'. Try adding this to the parameter list: single.opts = "'controls': ['first', 'previous', 'play', 'next', 'last', 'loop', 'speed'], 'delayMin': 0"
to get something like:
saveHTML(pp(), autoplay=FALSE, loop=FALSE,
verbose=FALSE, outdir = "new",
single.opts = "'controls': ['first', 'previous', 'play', 'next', 'last', 'loop', 'speed'], 'delayMin': 0")
The default list includes 'navigator' so we're just removing that option. You can reorder these options too if you want.
When creating a Excel 5 file through PHPExcel, I am able to display the background color cell in any color but as soon as I switch to Excel 2007, the background color remains constantly black, is there any fix available to sort it out? Here's the subset of my code where the goal is to display the column header in yellow, any help would be appreciated, thanks in advance:
$styleArrayTableHeader = array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'rotation' => 90,
'startcolor' => array(
'argb' => '#ffff00', // yellow
),
'endcolor' => array(
'argb' => '#ffff00',
),),);
$objPHPExcel->setActiveSheetIndex(0);
$worksheet = $objPHPExcel->getActiveSheet();
$worksheet->getStyle('B6:K6')->applyFromArray($styleArrayTableHeader);
.....
.....
you need check fill type of cell
if ( $pStyle->getFill()->getFillType() == PHPExcel_Style_Fill::FILL_NONE ) {
$color = 'white'
} else {
$color = '#' . $pStyle->getStartColor()->getRGB()
}
Can you retry with the latest develop branch code from github - there's at least one fix in there for the fill styling in Excel 2007...
Also you're using trying to set argb with rgb values. Either use argb values, or set rgb instead