I have to create label with 2 rows.
in OL 2 I've did it by adding '\n' in the text label but it seems that ol3 doesn't support it:
new ol.style.Style({
text : new ol.style.Text(/** #type {olx.style.TextOptions} */ ({
text:'line 1 \n line 2'
}))
})
How can I break the line between 1 & 2 ?
There is no support in the library currently but people have discussed solutions in the ol3-dev Google group as well as pull requests such as: https://github.com/openlayers/ol3/pull/3538
Related
I am testing some network packets of my Organisation's product. We already have custom plugins. I am trying to add some some more fields into those existing plugins (like conversion of 2 byte code to a string and assign it to a field)
Thankyou in advance for reading my query.
--edit
Wireshark version : 2.4.5 (organization's plugins dont work on latest wireshark application)
--edit
Problem statement:
I am able to add field and show value, but fieldname is not displayed as defined.
I cannot share the entire .lua file but i will try to explain What i did:
Below is the image where I have a field aprint.type. this is a two byte field. In .lua file, for display purpose it is appended with corresponding description using a custom function int_to_enum.
I want to add one more proto field aprint.typetext which will show the text.
What I did:
Added a protofield f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text") (Tried f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text",FT_STRING) also)
Below the code where subtree aprint.type is shown, added my required field as subtree:add(f_apr_msg_type_txt, msg_type_string) (Below is image of code extract)
I am able to see the text but field Name is shown as Wireshark Lua text (_ws.lua.text)
Normally displaying strings based on numeric values is accomplished by a value string lookup, so you'd have something like so:
local aprint_type_vals = {
[1] = "Foo",
[2] = "Bar",
[9] = "State alarm"
}
f_apr_msg_type = ProtoField.uint16("aprint.type", "Type", base.DEC, aprint_type_vals)
f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text", base.ASCII)
... then
local msg_type = tvb(offset, 2):le_uint()
subtree:add_le(f_apr_msg_type, tvb(offset, 2))
subtree:add(f_apr_msg_type_txt, tvb(offset, 2), (aprint_type_vals[msg_type] or "Unknown"))
--[[
Alternatively:
subtree:add(f_apr_msg_type_txt, tvb(offset, 2)):set_text("aprint_type_text: " .. (aprint_type_vals[msg_type] or "Unknown"))
--]]
I'm also not sure why you need the extra field with only the text when the text is already displayed with the existing field, but that's basically how you'd do it.
version
Rails 6.0.3
ruby 2.7.2
What I want to do
There is text_area_tag in haml file
text_area_tag("context[]",nil,:wrap=>"virtual",:rows=>"8")
Now I wanna add like this sentence as placeholder
placeholder test
Hi I'm Mike, placeholder
new line
new line
new line
Hi I'm Michelle
new line
new line
Hi I'm Goku
new line new line
(and more... and more...)
・
・
・
Problem
I could declare variable in view haml file like
- var = "placeholder test
Hi I'm Mike, placeholder
new line
new line .........."
but it's too long, super spaghetti code.
If I could use like javascript↓, It would be useful
const var = `
placeholder test
Hi I'm Mike, placeholder
new line
......
`
If somebody knows better way to declare variable with a lot of new line in haml file, let me know please.
To create new line, you can use "\n" direct on haml file, or use a variable like times4 in my way, and note not set the name to 4times, it will not working!
%h4 Content
- var = "placeholder test
Hi I'm Mike, placeholder
new line
new line .........."
- iso1 = "placeholder test \nHi I'm Mike, placeholder \nnew line \n \nnew line .........."
- times4 = "\n" * 4
- iso2 = "placeholder test \nHi I'm Mike, placeholder \nnew line #{times4}new line .........."
= text_area_tag("context[]",nil,:wrap=>"virtual",:rows=>"8", :placeholder=>"#{iso2}")
Happy coding!
Update for multi lines, you can use "|" in variable declaration, example:
- iso3 = "placeholder test \n" + |
"Hi I'm Mike, placeholder \n" + |
"new line #{times4}" + |
"new line .........." |
Note it ends with a "|", if not, you will get a error!
Do the more, door the move! : D
Good day everyone i want to achieve a new line in my spreadsheet cause i had two to three values here
This code over here has a protection so the viewers cannot edit easily in excell they must have password on the admin to be enable to edit.
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$spreadsheet->getActiveSheet()->getProtection()->setSheet(true);
$spreadsheet->getActiveSheet()->getProtection()->setSort(true);
$spreadsheet->getActiveSheet()->getProtection()->setInsertRows(true);
$spreadsheet->getActiveSheet()->getProtection()->setFormatCells(true);
$spreadsheet->getActiveSheet()->getProtection()->setPassword('test');
$spreadsheet->getActiveSheet()->getStyle('D')->getAlignment()->setWrapText(true);
$spreadsheet->getDefaultStyle()
->getFont()
->setName('Times New Roman')
->setSize(14);
$sheet->setCellValue('A1', 'Control Number');
$sheet->setCellValue('B1', 'Requesting Unit');
$sheet->setCellValue('C1', 'Project Details');
$sheet->setCellValue('D1', 'Attached Transaction Form');
This line of code uses to fetch the data in the database in this scenario my attached form has two to three values so thats why i want to create a break or a new line.
$data = $this->m->getlog1();
$slno = 1;
$start = 2;
foreach($data as $d){
$sheet->setCellValue('A'.$start, $d->control_number);
$sheet->setCellValue('B'.$start, $d->requesting_unit);
$sheet->setCellValue('C'.$start, $d->project_details);
$sheet->setCellValue('D'.$start, $d->attached_form);
$start = $start+1;
$slno = $slno+1;
}
You have to use line breakes in the text and
$spreadsheet->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true);
For more Information see documentation.
According to this commit this commit this will be automatically included in future releases.
Maybe you must/will use some auto fit then take a look to this code.
Is there a way that I can add a new line to a cell using the Axlsx gem in Rails?
So basically replicating in Excel once you enter a value you can do a Alt + Enter to add additional text to the new line in the cell. I tried
sheet.add_row ["Testing cell row 1" + \r\n + "Testing cell row 2"]
but that throws an error.
I recently had the same problem and I found a solution that works.
I used this to setup:
p = Axlsx::Package.new
p.use_shared_strings = true
And this code adds a wrap style that makes the \r line breaks work correctly:
wrap = p.workbook.styles.add_style alignment: {wrap_text: true}
sheet.add_row "1\r2\r3", style: wrap
Now the new line in cell works, and the output is:
1
2
3
Notes:
The new line in cell doesn't work (#Gary Pinkham)
The "\x0D\x0A" didn't work (#noel)
For a forced line feed use "\x0A" (breaks between paragraphs.)
If you want both carriage return and line feed, use "\x0D\x0A".
I couldn't comment on the "doesn't work in mac excel" comment so adding this as an answer.. use package.use_shared_strings = true.. needed for Mac Excel..
I would like to be able to add the page numbers in a word document to the header.
I have found some links that display the code in visual basic, but no matter what i try, i keep getting errors. It keeps telling me the either "sections" or "headers" or "footers" is not a supported automation object.
Any help would realy be great. Thank You.
Links:
http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/10/how-can-i-add-centered-page-numbers-to-the-footer-of-a-word-document.aspx
http://msdn.microsoft.com/en-us/library/office/ff194253(v=office.14).aspx
I Tried addapting the link's code with no success:
wrdDoc.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers.Add
and if possible please how to allign the page number right.
Use [] instead of () for indexes
//Headers[wdHeaderFooterPrimary] = Headers[1]
//Add possible values:
//wdAlignPageNumberCenter = 1
//wdAlignPageNumberInside = 3
//wdAlignPageNumberLeft = 0
//wdAlignPageNumberOutside = 4
//wdAlignPageNumberRight =2
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(1); //example with center alignment
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(2); //example with right alignment