PHPSpreadsheet clear formatting - phpspreadsheet

Im using PHPSpreadsheet to read and get data from an excel file and put the data into my database.
I used cell iterator to iterate data between cells. And i found that some data are not readable. I try to open that file using Microsoft Excel and do 'clear formatting', and then the PHPSpreadsheet can read it.
So my question is, how can PHPSpreadsheet clear the formatting for that spreadsheet file? To make sure PHPSpreadsheet can easily read the value. Thank you.
Note : That unreadable data is not a chinesse or any foreign character, it just a simple "AUKEY" string

You can set option setReadDataOnly on the reader, to instruct the
reader to ignore styling, data validation, … and just read cell data:
e.g.
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load("05featuredemo.xls");

Related

Writing List of object into CSV File in xamarin.Android

Can any one suggest me How to implement writing List of objects into .csv into device download storage in c# xamarin android.The data exported to csv should be having headers.each item in list should be written in row .something similar to image attached
To create a CSV string, you'd generally do this manually. As an example:
string headers = $"{Column1},{Column2}";
string row1 = $"{row1.ValueA},{row1.ValueB}";
...etc...
Then append them together, separated by newlines. Obviously you'd be better off doing the above in some kind of loop.
As for putting it into android download storage, someone else will have to tell you how to do that, I don't know how!
i have followed below link http://www.joe-stevens.com/2009/08/03/generate-a-csv-from-a-generic-list-of-objects-using-reflection-and-extension-methods/ that helped me to implement.

Programmatically generated CSV file format issue for Excel and Numbers

In my iOS project, I have programmatically generated csv file from my data. Most of time, it looks all good for Microsoft Excel and Apple Numbers to open with.
But when the cell data is something like 5 - 60, it seems Excel would automatically convert it to date value like May-60, while Numbers open it correctly.
I have found this thread: https://stackoverflow.com/a/165052/833885, so the solution makes Excel happy is using "=""5 - 60""". But this will make Numbers shows ="5 - 60"......
You can quickly generate empty csv file to test what I described above.
Is is possible to generate csv file that makes all world happy???
Thanks in advance.
You can create a new file in excel and import from the data ribbon tab - this gives options to specify the data types for 'columns' in the csv. A bit of a pain but will avoid the issue.

import data from xls and display in barchart

there is an xls file which needs to be displayed as a bar graph and on click on the column it needs to display data from xls file pertaining to that column representation on an IPAD .I am new to this but how do I proceed from here.Since its in xls format what can I do with that is there an inbuilt function which converts it into csv ?.Its an offline project .Kindly help me .Thanks in Advance.
Check out https://github.com/dhoerl/DHlibxls It has a nice wrapper around libxls. There are no built-in functions to convert from xls to csv, but you can easily write your own using this library.
I should note that libxls is LGPL, so be careful.

ASP.net MVC Export To Excel

I am currently exporting to Excel using the old HTML trick, where I set the MIME type to application/ms-excel. This gives the added benefit of nicely formatted tables, however the negative of the excel document not being native Excel format.
I could export it as CSV, but then this would not be formatted.
I have read brief snippets that you can export it as XML to create the Excel document, but cannot find too much information on this. Does anybody know of any tutorials and/or benefits of this? Can it be formatted tables using this method?
Thanks.
Easiest way, you could parse your table and export it in Excel XML format, see this for example: http://blogs.msdn.com/b/brian_jones/archive/2005/06/27/433152.aspx
It allows you to format the table as you whish (borders, fonts,colors, I think even formulas), and Excel will recognize it as native excel format. As a plus, you can use other programs that can import Excel XML (ie.Open office, Excel viewer,etc) and you do not need to have Office components installed on the server.
Check out ExcelXmlWriter.
We've been using it for some time and it works well. There are some downsides to the xml format however. Since it's unlikely your end users will have the .xml extension associated with Excel, you end up having to download files as .xls with an Excel mime type. When a user opens a file downloaded in this way they get a warning that the file is not in xls format. If they click through it, the file opens normally.
The only alternative is a paid library to generate native Excel files. That's certainly the best solution but last time we looked there were no good, free libraries (may have changed)
Bill Sternberger has blogged a very simple solution here:
export to excel or csv from asp.net mvc
Just today I had to write a routine that exported data to excel in an MVC application. Here's the details so someone may benefit in the future, first the user had to select some date ranges and areas for the report. On the post back, this method was in place, with TheModelTypeList containing the data from LINQ/Entity Framework/SQL Query returning strong types:
if (ExportToExcel) {
var stream = new MemoryStream();
var serializer = new XmlSerializer(typeof(List<SomeModelType>));
serializer.Serialize(stream, TheModelTypeList);
stream.Position = 0;
FSR = new FileStreamResult(stream, "application/vnd.ms-excel");
}
The only catch on this one was the file type was not known when opening so the system prompted for the application to open it... this is a result of the content being XML.... I'm still working on that.
I am using Spreadsheet Light, an Open-Source library that provides ridiculously easy creation, manipulation and saving of an Excel sheet from C#. You can have an MVC / WebAPI Controller do the work of creating the file and either
Return a URL link to the saved Excel file to the page and invoke Excel to open it with an ActiveX object
Return a Data Content Stream to the page
Return a URL link to the calling page to force an Open / Save As dialog
http://spreadsheetlight.com/

extract text from word or pdf based on format (font name and size)

I need to parse large text (about 1000 pages of word or pdf document)and place some of the text inside this document into database fields
I found that the only thing I can distinguish the text I want to extract is the format , it is always "Helvetica-Condensed" size 12
can I do that ? I know how to use the string functions but what I should use to test the format ?
as I said the text is stored inside word document or PDF
if there is third party component can do no problem please refer it to me
Thanks
There is QuickPDF. The price is $249,00.
The other option is to code it yourself. The file specification is available online, and if your only trying to rip the text out of the document this should guide you most of the way.
The only thing to be careful of are documents which are built entirely from images. In that scenario (no matter what you use to read the file) you will also need an OCR type of application. To see if this is the case or not, open a sample of the type of file you are wanting to "extract" text from, select the text to copy then try to paste into notepad.

Resources