Closed ootsun closed 7 years ago
Can you paste the row in for me to take a look at?
// Write the list into a xls file then save this file
using (var workbook = new XLWorkbook(XLEventTracking.Disabled))
{
using (var writer = new CsvWriter(new ExcelSerializer(workbook)))
{
writer.Configuration.RegisterClassMap<LeadClassMap>();
writer.WriteRecords(list);
}
workbook.SaveAs(pathString);
}
Not sure if it's what u asked to see
We can see with visual studio that it's a normal string
What if you open the file with a text editor instead of excel?
PK LjwJ±ùS º xl/workbook.xml ¢ ( Ïn!Æ_…̽²nbÛlD/öà¥iRÓž—¸Àf@Ýwë¡ÔW(¬MO=1ÿ~ß|ÃÏ×÷|9¸Ž‘¢
^ÀtRC¯‚¶~'àÌÃ3,ó¡9ÚoCس<ïcCÚ”ú†ó¨Zt2NB>÷L 'SNiǃ1VᨃCŸx]Uœ°“)ïŠí#\Ô†ÿ¨ÅžPêØ"&×Åœ´îݽËÞñU:°imü¼4€ñ2W‹§x•3–bz/âòH•ì7r;f™åàÑÇ-b~\ù2ô°±¶ÖjÔØÐZ×W¡«ÑXºøg‡Jvª\‘ŸÂOëÙS=»‚WÇ‹_PK LjwJÔ^S¨œ œ _rels/.rels ¢ ( <?xml version="1.0" encoding="utf-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="/xl/workbook.xml" Id="R3df90e6e225a477b" /><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="/docProps/app.xml" Id="rId1" /><Relationship Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="/package/services/metadata/core-properties/7a17c4849f0b4e2ca72c4a5b525d9f97.psmdcp" Id="R52c10e934b014bcf" /></Relationships>PK LjwJϵ
: docProps/app.xml ¢ ( “MNÃ0…¯¼oB…P”¸ª ¢,‘q&Eb[ö4J¹ŽÄp(iùìÆo¾Ì¼yR^žžãI]AÖI2†$ %t&Õ2!kÌ'dÂbn¢Ôj%¸À¢\TaBVˆ&¢Ô‰”Ü
=¡|3׶äèŸvIužKgZ¬KPHÃð˜fZ4ÓÜÍbcÀ‘·yÜüwÔƒl¶IëyjL!G»Âj§sfµ€"¦{ý†÷cç ÖVↅ-ÑWb.x§~ Ëyá e>´†8Þ„—ri‹+Œ*¨mpÏ4÷&¤âVr…$pòÑ?ǤÃ:µãв[mÜ ]L·b[öÙ~-ÇlÔ¾øìf]ò²àš«%üeÅá×+èöVÖƲ„pWyÊ-~Mkà=˜#Òó:«¶Øw¹×:HTx7µÀ§:+Ÿnî¹ß3Kwþ ö PK LjwJ>çÊa ÿ xl/sharedStrings.xml ¢ ( ’ÉNÃ0†_eäh¢ U]$J…8ÐF¥H\Ýdšy ö8*¼QoÜ9 ‘âp‚âÂeäñ|³ýöÇëÛp²U*´N=bǽ˜êÔdBç#æistÎ&ãávàAj¼¦ 1ðZ<zœþ\„2Ú ¶#V•ƒ(riŠ»ž)Q‡ØÆXÅ)¸6\i‘g®@$%£“8îGŠÍÚ6¢±4ž‚äàL*êÕ»aÔû}£SÀÄ8ⲹŔÐ[ÈxJ¢{ªµ}XUS
»¨ÄÖ;ý/ò’6›¤!ƒSù/Pí7"݈!×6О„Ž7˹n}”Â0£°Ø‰,æÓY²‚Ù}²€«åâ.é"Ùwè•;n r.%Z«3Xâ:Œ.[ïÙiòÖ͹ÍP;ÖUuUÔ;ûÔ½°^›®à2« ´Æ•á‰ƒbÍù ,jã+¸^Ái?~ùµßyü PK LjwJ'J|2â ¼ xl/rels/workbook.xml.rels ¢ ( µ’ANÃ0E¯bÍžL(¨B¨n7lº¥½€åL⨉my¦´=‹©WÀ aÄ‚M6¶üÇóôÆòíýºÚœÇA½Qâ>x
÷U
Š¼
Mï;
Giïž³^½Ò
$ß`×GV¹Å³'ŸÙ:
W!’Ï•6¤ÑH>¦£±Ó.êz‰é'J¦Ú"ý‡Ú¶·ôìq$/€‘IÔì$å ÔÞ¤ŽDž‡²Te2¨m£!m›P8Ÿ‘\ú2e…Ã㜧숤ÔøŽ?ß-o…ÐbN!ɽTÊLÑ×Zx,',þàúPK LjwJ´ÁmêM z
xl/styles.xml ¢ ( íVÛjÜ0ý¡÷F»†–²¬ÚC ¤¥ÙB_e{l«ÑÅHòÆ›ëC?©¿PÝì½Z¶”@¡û¢™ã9£¹IÚ￯FÁÑ´aJæxy±Àd¥j&Û¶yñ]®Ç•±;÷€EŽ!ÍjÌqgm¿"ÄTj.TÒ}k”Ô:U·Äôhm<Mp’-¯ˆ LbïQ¢Ö J
Òº@—›:Ç.žèðZÕcŒÈåšÌdOi”<õâ!¿º¼ìÎZ‰¶”縤8“œ¸”ž"¼\& R\i¤Û2ÇE±¿ôERÑøšrVj–ð†
ÆwñK6ÅwOB‘q>‡˜á òkO-§¢$ov½ËTª(Ùÿ–Ôjº[f/yI‘”J×®ÙÇåŠ ªm•¤üSÊ>©ïÔ£ô€·äÐXF!ø«²‘hïM4k»³ˆàm¬êÏá9󘑵JœCŒo4å}{â$W¾œb¨|œß{Ÿ›“Q›Óy—³èú–Äè*)´ïùîn%è"œßʈú¡ØkokÏ §A€< |ÐÊBeãùõ3‚¸ª Æ«k“’›Ÿ¢Ï²+|rÜ—©O£Ecó,ÉÒÉuJ³'—¿‹Z )Çþf·¬
—pŒ,Œö£²4:q{=jÚo&ë°¡5pg´…›=ôe0–5»[jì»Gf:ÍäÃFl¢Qÿx¼Ÿs!Ï2RÿËý‡å&óÈÝR'OÄŒ#ÿæøΗ–”½·L&-Ôý_ˆËPK LjwJryNÎm ˆ xl/worksheets/sheet.xml ¢ ( •ÝnÛ0…Åðýbç?
šmÒ´6¤h‡íZµéX¨,”Ü´}µ]ô‘ö
£¥¤H:ØH::!ú÷¯÷ó‹—JEÏ€V=‹»4Ž@g&—z;‹W|™Äóó—éÎà“-\D´â,.«§Ib³a;¦Mß
ƒ•pâ61E!3Xš¬©@»¤—¦£A G‡ÙRÖ6Þ«½üšDîMTˆUB긵ç³wØ.Mã”Ôp‡‘mªJàë(³£ÚâCâ^nKçÉü<9ÙœKrÚÞE„PÌâËîtÝóØžú!agO¢¨½™GcžÚ`ÏâôDötÃÊ—CÖr(D£Ü½ÙÝÂÞÍðøœ¥p¢
Ðì"Þk¡-¦g¾à¬M¶y" XŸž§íÙÏÞAöA^qd—#ÙãÈ%Gö9òš#¹âÈ!GÞpäˆ#o9rÌ‘kŽœœ‰ïÉQkzÿhM‘:c[sLêCkú)ÛÇ'ÛeÑ%‹²=¿fQ¶é«€vMìÒAg”ŽÓn2™°ÞüµevúýáÙ(
&¬¡[îNØ׬õ>Û³äÓãªQj·©ý4ŠJƒòÍh'Ô‚f „§L£ÑÉìS²¤9D2œ»E™¥cOŸ„ž ÜJÒUP³´3¦÷ᩇÀ™ú°|4Ιª†ApƸŒ‡Gâàš:ªE
ø ß rÙ®RrÑ2ô2¹Ùéï%è
UGT$â0}
CˆÎW"{ºÔùÏR:ðeä(¼í8Ê@©…©ÚNj£þˆ)Ê¥•x…|o-X_yÏ!ãÄ£‚;ÎF™i´;”ùPK LjwJu±‘^« » xl/theme/theme.xml ¢ ( íYMÛDþ+#ß[ÇIœfWM«M6i¡ÝvµŠzœ8{š±Çš™ì67Ô‘qAâÆ•Z‰Eü˜…"(Òþ^;^{œŒ»ÙvEl‰gü¼ß~Ç9þ闫׆!):–s¹f!y|L#¿cÍÔäRÛº~íÞT p$7qÇ
”Š7m[z°åe“îM¸±‚¥ðí±À‡À$dv½VkÙ!¦‘…"’Žuw2¡AÄ¥•3ï3øŠ”L6<&ö½T¢N‘bÇS'ù‘sÙcÖ±@ΘÉCe!†¥‚«–~,d_»jçTLUk„ƒôsB˜QŒ§õ”Pø£œÒ47®lê «À~¿ßë;Ç=¬uVÀÍAÛéæ\5Ôâr•{¯æÖšKš„Æ ÁF·Ûu7Ê‚ ¹BЮµš[õ2A³ pWmènõz2[´VW6ZÍ%‚0MWàId‹å˜ g7ø6àÛy.0[Ë´ƒHUå]ˆp1 @e¬h„Ô<&쮇Ñ 8•€7 Öne{ž\ÝKÄ!é «Žõ~Œ¡@ Ìñ‹ïŽ_<CÇ/ž=z~ôèÇ£Çý
¢¼‰#_§|õͧ}õúóÙׯž|^A u‚ß¾ÿøן?«@ùò‹§¿?úòËOþøö‰ ¿%ðHÇiH$ºCÑû"ÈHœ‘dZ"Á@MȾ JÈ;sÌŒÀ.)û𞀶
DÞ˜=(黈™¢&ä ,!w8g].Ì6ÝJÅi6Í"¿B¾˜éÀ=ŒŒâ{KQîÏbÈljdÚHIÕ]Ç>‰ˆBÉ=>%ÄDwŸÒ’w¨'¸ä…îSÔÅÔì˜!)3ÕMB€æF!ê%íÜC]ÎŒ¶ÉA
‚™‘)a%oÞÀ3…C³Ö8d:ô6VQÑý¹ðJŽ—
‚îÆQL¤4Ýó’Ê·0´(sì°yX†
E§Fèm̹ÝæÓ^€Ãج7üžœBÆb´Ë•Y^®™d
ÁQuäïQ¢ÎXìP?0'Krg&Nºz©?‡4z]³fºõE³^jÖ[ð3Ér‹®þGó6žE»$Iþ‹¾|Ñ—/úòk|ín\4[Ÿ«S†aå=¡Œí«9#·eÚº%è=ÀfºH‰ò¡>àòD^ èœ^#ÁÕ‡TûŽAŽ“ŠðeÆÛ—(æV%óôlJÁütÏÍ” Çj‡ûÒI3g”®|©‹j$,Ö׸ò¶âœrMyŽ[!Ï}½<[ó)ÔÂÉ›§UÏÔ”fdœx?ãps”ð˜d¡r̶8u}×>Ýuš¼ÆÛÊ['VºÀf•@÷<‚U[ –½Z,*¯Ð!(æÖ]y8îX¼à2Œ¡LZf~Ô±<•Ysjm/Û\‘ NÚæ’XHµe° Koå/e¢Â„ºÛLØ ¦þ´¦¶ó¯êa/G˜L&ÄS;Å2»ÇgŠˆý
|ˆFl&ö0hÞ\dÙ˜Jx”ÔOêµ™%¹dõ°üê'«Ìâ g=ªgÀŸ^çJ¤+M?»Bù7´¥qŽ¶¸ÿg[’ô…ñ¶1NÏa0Œ’<íX\¨€C?Šê L©0PAm¤-‹%¯°eÉÖÂL ÏÔõ‘ ÐõT ÙU™¥§psN:dV§¬ãä Ëxñ;"„ “"n%.°P·•Ì)p9p¶©ÆFþà]žŠšUSÑ)cC!ªy–)¥©?´gÃÆÛjqÆp½Â캻þ8†“ J¾ ‘Sá±bò=ÈT’—ÚY)æ›#кۗðúgg¬"íª¸Ÿëxªy¼QåñS¾¹Ç]ƒÃÝSüm¯¬yÒÕÊß]|ô „oÙjÆ”ÌÞK=„Óiïäß
”ÉL‰¯ý
PK
LjwJNUûýÚ Ú Q package/services/metadata/core-properties/7a17c4849f0b4e2ca72c4a5b525d9f97.psmdcp ¢ ( <?xml version="1.0" encoding="utf-8"?>
¼ xl/styles.xmlPK- LjwJryNÎm ˆ P xl/worksheets/sheet.xmlPK- LjwJu±‘^« » xl/theme/theme.xmlPK-
LjwJNUûýÚ Ú Q package/services/metadata/core-properties/7a17c4849f0b4e2ca72c4a5b525d9f97.psmdcpPK-
LjwJ½g].5 5 j [Content_Types].xmlPK
¾ ì
This might be easier... Can you write a short contained example that recreates the problem?
So you would like me to give you my C# file but with only what matters for this case? I can give you that, yes :)
Yes. Kinda like a unit test.
using System.Collections.Generic;
using CsvHelper;
using CsvHelper.Excel;
using System.IO;
using ClosedXML.Excel;
namespace ConsoleApplication2
{
public partial class Program
{
static void Main(string[] args)
{
IDictionary<string, string> map = new Dictionary<string, string>();
map.Add("1","Museums, art galleries, and botanical and zoological gardens");
map.Add("2", "example");
// Write the list into a xls file then save this file
using (var workbook = new XLWorkbook(XLEventTracking.Disabled))
{
using (var writer = new CsvWriter(new ExcelSerializer(workbook)))
{
writer.WriteRecords(map);
}
workbook.SaveAs(@"C:\Users\gabriel\Documents\Mes notes\file2.xlsx", false);
}
}
}
}
I got this :/
It seems to be the comas that causes the problem. How can I do to write "," in my file but not the """" around my string?
What is ExcelSerializer
?
I don't really know what this is. I found this solution on the Internet. How would u create a new xlsx file?
You may need to contact the CsvHelper.Excel
project and ask them this question. That serializer is what is doing the writing.
Ok ;) Thnaks
In case anyone else has trouble with this the solution (as noted in christophano/CsvHelper.Excel#6) it was fixed by setting writer.Configuration.QuoteNoFields = true;
Hello, when I export my string Museums, art galleries, and botanical and zoological gardens into a xlsx file, CsvHelper adds " " around it. Any idea why?