php - Format text to fit in columns in Excel -


I have this block of text in an array:

  "Stephen Olsson" Kangswa Žgen "Skolgaton" xxxx-xx-xx 0735xxxxxx, "PAR Davidson" "Skolgaton" "Mantovage" xxxx-xx-xx 0709xxxxxx,   

I parsed this kind of a CSV -File content, for use in Excel later, however, I want to fit this text with excellence in different columns. So, when I open CSV-file in Excel, I A column should be named, except the address in the column etc. How can I achieve this? Should I use PHPExcel? Or can this be done with plain old PHP?

This is my PHP-code

  $ gatunamn = $ _POST ['gata']; $ Ort = $ _POST ['Omrade']; $ Csv_data = array (); $ newSpider- & gt; ; Fetch page ($ gatunamn, $ ort, offset = 0); $ Obj = json_decode ($ newSpider-> html); echo "& lt; Div id = 'rightcontent' & gt; & Lt; The table id = 'one-column-emphasis' & gt; "; encoded ;  the address    input type = 'Checkbox' name = 'csv_all' id = 'csv_all' & gt; & lt; / th> gt; Ad & gt; Adress2 & lt; / th & gt; & lt; th & gt; Adress3 & lt; / Th >> gt; & lt; th & gt; Personnummer & lt; / th & gt; & lt; th & gt; Telefonnummer & lt; / th & gt; & lt; th & gt; Telefonnummer2 & lt; / th & gt; "; $ Antal_sidor = round ($ obj-> search-> gtc- gt; total hits / $ obj-> search-> wp- & gt; pages); Echo "& lt; td> & lt; / td & gt;"; Foreign exchange ($ obj-> search-> WP-> FEATURES $ FISH AS) // HOPAR UT 50ST (POSESIZE) {echo "<"> <;; Echo "& lt; td & gt; & lt; input type = 'checkbox' value = 'csv' class = 'csv' & gt; & lt; / td & gt;"; Echo "& lt; td & gt;" . $ Fish- & gt; Name "& lt; / td & gt;"; $ Csv_data [] = Utf8_decode ($ fish- & gt; name); Foreign exchange ($ fish-> addresses as $ advertisement) {echo "" . $ Advertising-> Label "" $ ad- & gt; Pincode "" $ ad- & gt; Area "& lt; / td & gt;"; $ Csv_data [] = utf8_decode ($ ad-> label. "". $ ad-> Pincode. "". $ ad- & gt; area); } If (empty ($ fish- & gt; date offbrand)) {$ convert_date = substr ($ fish-> dateoffbirth, 0, -3); // Geor om Datam franaden a timestamp echo " . Date ("Y-M-D", $ Convert_date) "& lt; / td & gt;"; $ Convert_data = Date ("Y-M-D", $ Convert_date); $ Csv_data [] $$ Convert_data; } If (empty! (Fish- & gt; phone number)) {foreach ($ fish-> as phone $ $ ph) {echo " . $ PH "& lt; / td & gt;"; $ Csv_data [] = $ Ph ""; }} Echo "& lt; / tr & gt;"; } Resonates "& lt; / table & gt;"; $ J = 0; ($ I = 1; $ i & lt; = $ antal_sidor; $ i ++) {echo " ";} if (isset ($ _ POST ['export'])) {$ fp = fopen (" eniroo.csv "," w "); Forward (explosion (", ", implode (" $ Ref ($ csv_data)) as $ rad] {fputcsv ($ fp, array (implode (',', str_getcsv ($ rad, "\ n"))));} echo "& lt; Div id = 'csv_info' & gt; "echo" & lt; A href = 'eniro.csv' & gt; Hmata CSV-file & lt; / A & gt; "; echo" & lt; / Div> ";}    

  // lines in the original array Rebuild $ myDataArray = array_chunk ($ MyDataArray, 5); // then write CSV $ FP = FOPN ('file.csv', 'w'); Forex Currency ($ myDataArray $ as Data Rau) {fputcsv ( $ fh, $ dataRow);} Fclose ($ fh)    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -