Auto Height in LibreOffice Calc - phpexcel

Typical you would format auto height rows with PHPExcel like this:
$file = new PHPExcel();
$file->getActiveSheet()->setCellValue('A1', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.');
$file->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
$file->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true);
$writer = PHPExcel_IOFactory::createWriter($file, 'Excel2007');
$writer->save(str_replace('.php', '.xlsx', __FILE__));
The problem is this doesn't work well when you open such a file with LibreOffice Calc. Instead you have to select the cell, choose Format Cells... and click OK.
It seems this is a known bug but unfortunately the proposed solution by adding the following else block into Classes\PHPExcel\Writer\Excel2007\Worksheet.php at line 1004 doesn't seem to work:
else {
$objWriter->writeAttribute('customHeight', 'false');
$objWriter->writeAttribute('ht', '0');
}
How could this be fixed?

Seems like that's a known bug in Libre Office. Detailed discussion here: https://phpexcel.codeplex.com/discussions/429322

Related

React Store Component in a string in a variable and print it out in return

I have a Card with a title and a description. In the description there is a phrase that needs to be shown in bold. Something like:
Lorem Ipsum dolor sit amet. The card is made with styled-components and the requirement is that in the end only the components are rendered with their props so that the code looks clean.
My first solution was something like
<Card>
<CardTitle>{card.title}</CardTitle>
<CardDescription>Lorem Ipsum,{""}
<CardBoldText>dolor sit
</CardBoldText>,amet
</CardDescription>
</Card>
This worked just fine, however the requirement is that in the return itself something like this is not written, for the sake of clarity.
In the CardBoldText component is defined, how the bold-text should be styled.
I am now looking for something to declare before the return like:
const cardContent = {
title: "CARD TITLE",
description: "Lorem Ipsum,{" "}
<CardBoldText>dolor sit </CardBoldText>,
amet"
}
(so to include the Bold-Component in that string)
to then be able to write this:
<Card>
<CardTitle>{card.title}</CardTitle>
<CardDescription>{card.description}</CardDescription>
</Card>
Unfortunately, instead of
'Lorem Ipsum, dolor sit, amet'
, it only gives me
'Lorem Ipsum, [Object object], amet'
and I just can't find a solution for it.... Help anyone?

add space between react-alice-carousel items?

I tried to create a carousel with this module and I need autoWidth property for my carousel. and the problem is my items are stick to each other and they need some gap in between, but there is no property for such. I tried to change the class margin property on the module itself but no luck. how can I fix this?
const LatestHotels = () => {
const items = [
<CardPrimary
title="Premium Hotel Plaza"
description="Sed interdum metus at nisi tempor laoreet. Integer gravida orci
a justo sodales."
location="27th Brooklyn New York, USA"
rating="4.1"
price={105}
/>,
<CardPrimary
title="Premium Hotel Plaza"
description="Sed interdum metus at nisi tempor laoreet. Integer gravida orci
a justo sodales."
location="27th Brooklyn New York, USA"
rating="4.1"
price={105}
/>,
// truncated for simplicity
];
return (
<div className={LatestHotelsStyles.mainContainer}>
<Header
title="Popular Destination"
subTitle="Explore some of the best tips from around the city from our partners and friends."
/>
<AliceCarousel
infinite
mouseTracking
items={items}
autoPlay
autoWidth
disableDotsControls
autoPlayInterval={4000}
renderNextButton={() => {
return (
<div className={LatestHotelsStyles.carouselNextBtn}>{">"}</div>
);
}}
renderPrevButton={() => {
return (
<div className={LatestHotelsStyles.carouselPrevBtn}>{"<"}</div>
);
}}
/>
</div>
);
};
result:
what I expect to be:
One way that i could find its to add a vertical padding or margin to each item component, so that they have this space between the items, just have to make sure that the first and last element dont have that lateral padding/margin cause that would make the starting and finishing items position a little bit off
.space {
margin: 0 12px;
}
.space:last-child, .space:first-child {
margin: 0;
}

Change inactive selection color in Firefox

When i select some text in Firefox and then the window or Iframe loses focus (selecting address bar for Example), then the selection becomes grey, even when a different color is specified in css.
How do i change the color for a disabled selection in Firefox?
What I've tried:
<style>::selection { background-color: green; }</style>
<p>lorem ipsum</p>
Edit:
What i want to use here seem to be ::inactive-selection, but it's not yet implemented in firefox. See https://drafts.csswg.org/css-pseudo-4/#selectordef-inactive-selection
Related bug: https://bugzilla.mozilla.org/show_bug.cgi?id=706209
Does anyone know a workaround? At this point, im considering using some javascript hacks. Any ideas how to do this?
No, you can't
Not on Firefox at least.
Reason I'm answering with a no, is to save both of your time and others who might try to find some solutions / hacks.
Since you already know about the css specification. I might want to add that,
Remember Firefox has it's own version of ::selection, ::-moz-selection. It also has it's own version of :window-inactive, :-moz-window-inactive. Unfortunately using these things together doesn't work.
Source: CSS Tricks
/* Does work */
::-moz-selection {
background: rgba(255,0,0,0.9);
color: white;
}
/* Doesn't work */
::-moz-selection:-moz-window-inactive {
background: rgba(255,0,0,0.3);
}
/* Nor this */
:-moz-window-inactive::-moz-selection {
background: rgba(255,0,0,0.3);
}
Also, Bugzilla has years old bugs requesting this feature and talking about it's inability to handle inactive selections but no responses on those. Here is a list. Some of them are even 11 years old. I am planning to talk to someone about this and report a new bug myself with some more details, might add their response or the bug number here so that you can get updates.
So, for now I think you shouldn't be looking for some hacks, it'll only waste your time.
Thanks
Update: here is the bug to keep an eye on bugzilla, lets see what the dev team has to say.
For text-selection inside a single node/element, a possible workaround can be achieved with javascript.
You can listen for the focus and blur events of the window.
In the event-handler for the blur-event you can check if anything is selected, wrap a span-element around the selected text and clear the selection.
In the event-handler for the focus-event, you can restore the content and selection to its previous states.
Demo:
let range = null;
let span = null;
// browser-window looses focus (blur)
window.addEventListener('blur', function(event){
let selection = window.getSelection();
// abort if selection involves text from multiple nodes
if (selection.anchorNode != selection.focusNode) {
console.log('Selection over multiple nodes is not supported!');
return;
}
// get range from current selection and wrap content in span with custom style
range = selection.getRangeAt(0);
span = document.createElement("span");
span.classList.add("selection-custom-highlight");
span.appendChild(range.extractContents());
range.insertNode(span);
// clear current selection in document
selection.removeAllRanges();
});
// browser-window gets focus
window.addEventListener('focus', function(event){
if (span) {
let selection = window.getSelection();
// replace span with text-node
let node = document.createTextNode(span.textContent)
span.remove();
range.insertNode(node);
span = null;
// clear current selection in document
selection.removeAllRanges();
// add saved range to selection
selection.addRange(range);
}
});
::selection,
.selection-custom-highlight {
background-color: green;
}
<div id="content-1">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
<hr>
<div id="content-2">
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
It is also possible to extend this workaround to handle text-selection over multiple rows:
For that you will have to wrap spans around the selection in anchorNode and focusNode utilizing the values of anchorOffset and focusOffset.
You also have to find all the text-nodes between anchorNode and focusNode (See this answer). And wrap each content in a span-node.
And when the window regains the focus, you would have to undo all the modifications.
Note: This can result in a lot of manipulations to the document and probably lead to some unwanted behavior when using any javascript libraries that interact or attach to these nodes.
Have you tried:
::-moz-selection {
background-color: green;
}
If the browser doesn't support a feature, you can't use this feature.
I know this is not the best answer, but you should try a different browser.
Actually i use Brave! He has all the features that Google Chrome has, because is based on Chromium. It's faster, blocks ads and trackers (you can disable), make HTTPS upgrades, load websites faster and much more.
Brave is an Open-Source project at GitHub: https://github.com/brave
You should try!

Can CSS psuedo content pull the element's text?

<p class="test">Lorem Ipsum Dolor.</p>
Can a CSS psuedo-element's (:before/:after) content property pull from the DOM element's plain text?
.test:after{ content: html; }
With the result of...
Lorem Ipsum Dolor.Lorem Ipsum Dolor.
Looking for a non-JavaScript solution (if one is possible).
Thanks :)
No, it's currently not possible to retrieve the element's text and display it using the content property without using JavaScript. However, as I pointed out in the comments, you can use the CSS attr() function in order to retrieve the element's attribute value and display it.
For instance, you could add a custom data-content attribute to the element:
[data-content]:after {
content: attr(data-content);
}
<p data-content="Lorem Ipsum Dolor."></p>
If you want to display the same string twice (as your question implies), you could simply use multiple attr() functions:
[data-content]:after {
content: attr(data-content) ' ' attr(data-content);
}
<p data-content="Lorem Ipsum Dolor."></p>
If you use JavaScript, you could simply iterate over the elements and add a custom data-content attribute to the element(s) based on the textContent property of the element:
[].forEach.call(document.querySelectorAll('[data-content]'), function (element) {
element.dataset.content = element.textContent;
});
[data-content]:after {
content: ' ' attr(data-content);
}
<p data-content>Lorem Ipsum Dolor.</p>
<p data-content>Some other string.</p>
It's also worth mentioning that the content property's value is still rendered as a string (and not HTML).

SCSS dynamic color changing [duplicate]

This question already has an answer here:
SASS: randomly pick background-image from a list
(1 answer)
Closed 7 years ago.
I just started using SCSS and I've been having some problems on dynamically changing the color of my website. What I want to do is create a list of colors and every time I refresh the page, it changes the color selected. Here is the code:
SCSS:
$colors: (
#cc6698,
#0869ad,
#ff8300,
#7A86b8,
#f05133,
#2aa9e0,
#71bf45,
#ef0e39,
#9e79d7,
);
$color: nth($colors, random(length($colors)));
However, it changes the color only when I modify the file, not on every page refresh. What should I do? Thanks.
Your code works, but you have to compile your SCSS files (using sass.js) in the browser to see the effect.
HTML:
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolor maiores placeat illo culpa quam, magnam sunt accusantium enim dicta temporibus, reiciendis soluta iure, reprehenderit qui vel perspiciatis suscipit earum asperiores.</p>
SASS:
$colors: (
#cc6698,
#0869ad,
#ff8300,
#7A86b8,
#f05133,
#2aa9e0,
#71bf45,
#ef0e39,
#9e79d7,
);
$color: nth($colors, random(length($colors)));
body {
color: $color;
}
Check this (to see the effect add text to paragraph or refresh the page):
CODEPEN

Resources