I am stuck trying to insert 2 values in an object that has 2 arrays in it. I tried looping through the 1st object, then the 2nd, but whenever I insert the data, it only inserts the value (the second loop)at index 0 instead of inserting the value at index 0,1 and so on. For example, it would only insert the value Air Canada instead of inserting Air canada and Air Canada Rouge
Here is the code and picture below to view the JSON file in order to get a better picture of my problem (the yellow highlights in my picture are the key things to look for)
Code (React)
addClosedCRs = _ => {
this.state.jiraCLOSEDCRsAccepted.issues && Object.keys(this.state.jiraCLOSEDCRsAccepted.issues).map((issue, i) => (
this.state.jiraCLOSEDCRsAccepted.issues && this.state.jiraCLOSEDCRsAccepted.issues[i].fields && this.state.jiraCLOSEDCRsAccepted.issues[i].fields.customfield_11400 && Object.keys(this.state.jiraCLOSEDCRsAccepted.issues[i].fields.customfield_11400).map((field, customfield_11400_index) => (
fetch(`http://ca-fpscfb2:2000/ClosedCRs/add?supNumber=${this.state.jiraCLOSEDCRsAccepted.issues[i].key}&Airline=${this.state.jiraCLOSEDCRsAccepted.issues[i].fields.customfield_11400[customfield_11400_index].value}&Product=${this.state.jiraCLOSEDCRsAccepted.issues[i].fields.customfield_11600.value}&Title=${this.state.jiraCLOSEDCRsAccepted.issues[i].fields.summary}&Status=${this.state.jiraCLOSEDCRsAccepted.issues[i].fields.status.name}&DateCRRequestReceived=${this.state.jiraCLOSEDCRsAccepted.issues[i].fields.created.slice(0, 10)}&EcrNumber=${this.state.jiraCLOSEDCRsAccepted.issues[i].fields.customfield_10800}&supNumberLink=<div><a target="_blank" href="http://ksr-ca-qmaltjira.ca.kronos.com:8061/browse/${this.state.jiraCLOSEDCRsAccepted.issues[i].key}">${this.state.jiraCLOSEDCRsAccepted.issues[i].key}</a></div>`)
))
))
}
componentDidMount(){
this.addClosedCRs();
}
I have a Perl script that converts text to HTML using HTML::TextToHTML
Some of the original text has quasi-tables in that their alignment matters.
For example
Job no Description Completed
15 Paving from NE 32 to 45th 11-01-17
Right now I am using this code
use HTML::TextToHTML;
my $conv = new HTML::TextToHTML();
if ( $HTML eq 'Y' ) { # convert entire body to HTML
$body = $conv->process_chunk($body);
}
But with the code above the lines often lose the appropriate spacing on some email clients.
Is there a way in HTML::TextToHTML to preserve the width of rows and their alignment?
You won't do much better than setting
make_tables => 1
in the constructor, and possibly setting
table_type => { ALIGN => 1, PGSQL => 0, BORDER => 0, DELIM => 0 }
which will split words that are separated by two or more spaces into the columns of a table
But you may well have to edit your original text file a little to get the best results. For instance your column headings will be Job no Description and Completed because there is only a single space after Job no
I am generating a downloadable excel file from mysql database using phpexcel. In that, there is a field having 18 digit number, which in the mysql, it is defined as Bigint. The number is defined as a hyperlink in the code. Now, there is the following problem -
The last 4 digits of the number hyperlink are displayed as 0000 although on clicking the number hyperlink, it is opening correctly. Example 860814069447613475 is shown as 860814069447610000 in the generated excel
Here is my code -
$objPHPExcel->getActiveSheet()
->getStyle('A'.(string)$n)
->getNumberFormat()
->setFormatCode(
PHPExcel_Style_NumberFormat::FORMAT_NUMBER
);
$n = 2;
while ($row = mysqli_fetch_array($result)){
$objPHPExcel->getActiveSheet()->setCellValue('A'.(string)$n,
$row['t_id']);
$objPHPExcel->getActiveSheet()->setCellValue('B'.(string)$n,
$row['t_text']);
$objPHPExcel->getActiveSheet()->setCellValue('C'.(string)$n,
$row['user_name']);
$objPHPExcel->getActiveSheet()->setCellValue('D'.(string)$n,
$row['description']);
$objPHPExcel->getActiveSheet()->setCellValue('E'.(string)$n
,$row['time']);
$objPHPExcel->getActiveSheet()->setCellValue('F'.(string)$n,
$row['place']);
$objPHPExcel->getActiveSheet()->getStyle("A$n:F$n")->getAlignment()-
>setWrapText(true);
$objPHPExcel->getActiveSheet()
->getCell('A'.(string)$n)
->getHyperlink()
->setUrl('http://t.com/'.$row['user_name'].'/status/' . $row['t_id']);
// Config
$link_style_array = [
'font' => [
'color' => ['rgb' => '0000FF'],
'underline' => 'single'
]
];
// Set it!
$objPHPExcel->getActiveSheet()->getStyle('A'.(string)$n)->applyFromArray($link_style_array);
$n++;
}
Found code which worked for me -
setCellValueExplicit('A'.(string)$n, $row['t_id'],
PHPExcel_Cell_DataType::TYPE_STRING);
I am using the output widget of tablesorter to get my table as csv (for excel). The table has no problems with special chars. If I export the data as output its all fine. If I use download option special characters like & are shown as & (seen in Notepad++) so Excel decides to separate it as there is a ;
Any help?
UPDATE:
http://jsfiddle.net/abkNM/6503/
Thanks!
Ok, I ended up adding a new callback function output_formatContent*. Use it as follows (demo):
output_formatContent: function (config, widgetOptions, data) {
// data.isHeader (boolean) = true if processing a header cell
// data.$cell = jQuery object of the cell currently being processed
// data.content = processed cell content
// (spaces trimmed, quotes added/replaced, etc)
// **********
// use data.$cell.html() to get the original cell content
return data.content.replace(/&/g, '&');
}
if you want to replace all HTML codes, then check out Mathias Bynens he which would work as follows:
output_formatContent : function( c, wo, data ) {
// replace all HTML shortcut codes
// (e.g. 'foo © bar ≠ baz 𝌆 qux' becomes 'foo © bar ≠ baz 𝌆 qux' )
return he.decode( data.content );
}
* Note: the new output widget callback is currently only available in the master branch of the tablesorter repository. It will be included in the next update.
I am trying to modify this terrific VIM script however both the original and my modified version have a maddening bug in which sometimes the cursor is shown in the wrong place. The simplest example that I could make is the 71 line text file below. Note that whitespace is important when copying the file.
<?php
/**
* Some silly method
*
* #param string Some silly string
*/
function someFunction()
{
global $class, $cv, $go, $pae;
global $messages, $counters, $ltn;
global $sh, $sub, $temp;
$charsets = array(
'us',
'si',
'pr',
'op',
'co',
'pa',
'av',
'pr',
'al',
'pc',
'pe',
'pi',
'pp',
'su',
'qu',
'de',
'ze',
'xo',
'mo',
'wo',
'de',
'mo',
'de',
'mo',
'dr',
'mo',
'de',
'mo',
'ev',
'pa',
'so',
'ms',
'bu',
'at',
'cu',
'pr',
'de',
'mo',
'nv',
'nl',
'nf',
'ne',
'nq',
'nt'
);
}
This is the relevant .vimrc file with the function:
set cul
hi CursorLine term=none cterm=none ctermbg=20
set nu
set statusline+=%{WhatFunctionAreWeIn()}
set laststatus=2
fun WhatFunctionAreWeIn()
let strList = ["while", "foreach", "ifelse", "if else", "for", "if", "else", "try", "catch", "case"]
let foundcontrol = 1
let position = ""
normal mz
while (foundcontrol)
let foundcontrol = 0
" The idea here is to go back to non-whitespace character before
" the last hanging open { and to check if it is a close paran.
" If so, then go to the matching open paren and search for the
" preceding it.
" If not, then go ahead and check the keyword right there.
normal [{
?\S
let tempchar = getline(".")[col(".") - 1]
if (match(tempchar, ")") >=0 )
normal %
?\S
endif
let tempstring = getline(".")
for item in strList
if( match(tempstring,item) >= 0 )
let position = item . " - " . position
let foundcontrol = 1
break
endif
endfor
if(foundcontrol == 0)
normal `z
return tempstring.position
endif
endwhile
normal `z
return tempstring.position
endfun
Starting from the beginning of the file, press j repeatedly until you get to line 63. Note that the highlighted cursorline stays on the correct line (63) but the cursor is shown on line 55. Jumping directly to line 63 won't trigger the bug, only pressing j repeatedly until you get to that line will.
Why does that happen, and how can I fix it? Note that when the cursor appears to be in the wrong place, pressing ``z` does in fact snap the cursor to the correct location. This is on VIM 7.3.154 on Kubuntu 11.10.
EDIT:
I notice by testing in other installs (Debian, CentOS) that the bug is not determinate, it happens occasionally but not in the same place on every system! You can test this code by pressing j and paying attention to the cursor location in whatever PHP files that you might have strung about. I would say that about one line out of every hundred lines triggers the bug in which the cursor appears to be in the wrong place.
I'm slightly confused by the logic of this function, but I suspect it is the ?\S which is causing the problems. It is searching backwards for a non-whitespace character, and wrapping around to the bottom of the file once it has reached the top.
Try replacing both occurrences of ?\S with
call search('\S','bW')
(Here the b flag searches backwards, and W prevents wrapping around the file.)
EDIT (2nd attempt)
The function also causes lots of jumping around of the view. The root of this is continually setting the mark mz and jumping to and fro. A better approach in vimscripts is to use the following commands to save the current view (instead of normal mz):
let pos=getpos(".") " This saves the cursor position
let view=winsaveview() " This saves the window view
You can then use these to restore the view:
call cursor(pos) " This restores the cursor position to that of "pos"
call winrestview(view) " This restores the window view to that of "view"
So I would use call cursor(pos) instead of `z and call winrestview(view) just before the return commands. This ensures that the function doesn't modify the appearance of the window, and makes for more pleasant usage.
Hope this helps!