-1

I create .CSV files by building the content like this:

s= "column1, column2, column3 \r\n"
s+= "R2column1, R2column2, R2column3 \r\n"
saveas("file.csv", s);

I now need to include a way to resize the columns when viewed in Excel.

I've read that CSV cannot do this, so what is the next simplest excel file format that can? And how would new syntax look?

Leviathan
  • 2,468
  • 1
  • 18
  • 24
doggy
  • 75
  • 1
  • 8
  • Excel files include formatting. What language is that code above? Maybe you should tag with that. Also, explain the bigger picture of what you want to achieve. Why not just open Excel??? – teylyn Feb 16 '17 at 21:31
  • I am generating a spreadsheet to be emailed from android, but the columns are squished. – doggy Feb 17 '17 at 14:37

1 Answers1

1

CSV files are simple text files that contain plain data. You can open these files in Excel, and it will be displayed in the spreadsheet view for convenience, with each field separated by the separator (in your case the ,) in a separate cell.

Although you can change the width of an Excel column, this is purely a visual style in Excel and can only be saved in an Excel file.

The solution would therefore be to convert your CSV files to Excel (*.xlsx) files.

Depending on the language you use you can probably directly create Excel files, without the need for conversion. There are libraries available for most programming languages for exactly that purpose.

If you want to create Excel files with Android, this might help: How to create an excel file in android?

Leviathan
  • 2,468
  • 1
  • 18
  • 24
  • JExcelApi worked great!! alot of dead links in that thread so i will repost the link that worked for me!!! http://jexcelapi.sourceforge.net/ – doggy Mar 06 '17 at 18:24
  • still here?I am having a problem on build, debug works OK, id' re post but im almost out of points and cant afford more down votes! any ideas?this is the beginning of the error code: Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Reference to metadata item 'System.String System.Globalization.CultureInfo::get_IetfLanguageTag()' (defined in 'CSharpJExcel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'CSharpJExcel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' couldnt be resolved.--->Mono.Cecil.ResolutionException:Failed to resolve System.String... – doggy Mar 09 '17 at 19:47
  • 1
    You should post this as a new question, since it is unrelated to this one. If you are afraid of posting low-quality questions, you should follow the advice given at https://stackoverflow.com/help/how-to-ask to improve the experience - not only for you - but for all of us. – Leviathan Mar 09 '17 at 21:06