How to read text file and save it in excel sheet using asp.net c# - c#-3.0

I have one text file with the below structure
10180,65,395,
10182,65,395,
10183,65,395,
10185,65,395,
I need that after read the text file, the cell in the excel sheet contains the value as below
fristcell, secondcell, thirdcell
10180 65 395
means after the commas the value placed in the new cell.
I read the text file with the commas, but not get how to insert it or import data in excel.
Please guide me.
Thanks

Since want to write to an excel file and save it and considering that your scenario is not too complicated, I would recommend Closed XML which is a wrapper around Open XML SDK
Go through the Closed XML documentation. That should help you get started.
The general way I would go about this is :
1. Read the text file into a List<string>.
2. Create a file using Closed XML.

Related

Extracting data from complex output text file using perl and placing into new text file

The complete output text file is hundreds of lines long, with relevant nuclear cross sections and a plethora of other data that I do not need for this particular problem. I am trying to extract the columns of data under "BURNUP" and the first "K-INF" from the file I attached. I am trying to extract this data and place it into a separate file. I am a newbie, and have a similar perl script from a professor. I have tried to adapt it to the information I am looking for but the only result I am receiving are the 2 print statements. Any suggestions?

Find corrupt data in xlsx file

We are generating xlsx files using a perl script. Files usually contains thousands of records. This makes spotting errors a very difficult operation.
This process was working since years without problems.
This week we got a request to check a file which contains errors. While opening Excel prompted that the file contains errors and asked whether we want to repair them.
In fact we do not want to recover the data but want to know which part of the file is corrupt. The error should be coming from corrupt data and we are interested to identify these data.
the log message shows the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<logFileName>error068200_01.xml</logFileName> </br>
<summary>Errors were detected in file 'D:\Temp\20161020\file_name.xlsx'</summary>
<repairedRecords summary="Following is a list of repairs:"><repairedRecord>Repaired Records: Cell information from /xl/worksheets/sheet1.xml part</repairedRecord>
</repairedRecords>
</recoveryLog>
The error should come from corrupt data. Is there any tool/method which helps to spot this corrupt data?
I tried renaming it a zip file, extracting it and opening it via an XML editor but was not able to find any errors in XML file.
We also checked that the different XML file structures are fine.
Thank you and best regards
As expected, the problem was coming from text cells containing numbers having an E in the middle.I used the following steps to identify the erronous cells.
1. Wrote small Java class to read the file. The class was checking the cell type and displaying the value afterwards.The java program generated an Exception at some line "Cannot get a numeric value from a text cell" even If I was correctly checking the cell type before displaying the content.
2. I checked the opened Excel file at that line and found that the cell contains only 'inf'.
3. I opened the file using open office and looked at the same cells. They contain 0.
4. I debugged the program generating the data and found out that these cells contain data like '914E5514'. Seems that E which was interpreted by Excel as an exponent.We changed the program to use the format '#' for that cell and this solved the issue.
Thank you.
Thank you very much, you helped me a lot by saying that 1 particular content item may be the root problem.
My corrupted content was https://www.example.com XYZ ... ASDAS
Solution: www.example.com XYZ ... ASDAS
This is something which cannot be handled by excel. Would be nice to have a list of thing which do not work

Reading from Excel gives ####### in some columns

I am using powershell to read data from a .xls file. All goes well, no need to display the code. But I have an issue that I have no idea how to solve.
Some columns in the excel are not wide enough to display their data:
In reality:
2016.04.01
As the column is displayed when opening the file:
########
When I am reading from the excel, the cell content I get in powershell is actually ########, not the actual cell content (= a date in this case).
I am reading 1000's of Excel files, all with the same issue. How can I fix this in my code? Is there a flag I need to set that I don't know about?
Any help would be much appreciated!

Create Excel file in iPhone programmatically

I want to create a Excel supported file which contains strings and images programmatically. I tried to create a .csv file, but I am not able to .csv file with both string and image.
There are many possibilities. The easiest way is to create CSV-Files but you have to take care which seperators excel uses. For checking that you should create a spreadsheet in excel and save it as csv and take a look into that file using any text-editor.
Another approach is to use SpreadsheetML and here a link to the msdn XML Spreadsheet Reference
Otherwise just create a simple xlsx-file with excel, unzip that file and take a look into that the unziped files.

Create PDF from CSV on iPhone

An iPhone app which I am creating generates reports from a Core Data database as a CSV file, which can then be emailed so that the user may use that data elsewhere outside of the app. I would also like to offer the ability to generate the same reports as a PDF file (of course, with nicer formatting) allowing the user to immediately print the report rather than having to jump through several hoops as with the CSV file - i.e. open in another application (e.g. Excel, Numbers) then reformat the columns (so they are wide enough for printing), bold the headings, etc.
Essentially, I want to provide the PDF file so that the user is immediately given a nicely formatted report, and they only need to export the CSV file if they wish to do data manipulation and need a format which is editable.
I was thinking that the easiest method would be taking the CSV file and the converting this into a PDF file, which would be the same as the CSV except would incorporate nicer formatting (such as a tabular layout) rather than the simple comma-separated format of the CSV file. I have been unable to find any ready-made classes for this purpose (to avoid reinventing the wheel) and I am unsure how to approach this since I have limited experience with this aspect of the SDK. Any suggestions or pointers in the right direction would be much appreciated.
You have two different problems:
Read CSV data into some structure in memory
Turn some structure in memory into a PDF
Aaron Saunders has posted some links for step 2, so here's a link for step 1:
http://github.com/davedelong/CHCSVParser
That's a CSV parser I wrote that will turn your CSV file into an NSArray of NSArrays of NSStrings.