how can i export set of data in SQL or Access to text file with text align ?
there is a AS400 system. witch employees have to enter Purchase orders one by one.
(customers send their Purchase orders by Excel)
i created a tool using C# to import excel and import to a access DB
and i want to know how to export to a text file with correct text length.(so i can import to the System Direcly)
this is the format i want
Name| Width|Type|Alignment|Remark
NO|10| N| Right left | pad with blank
Type|2| C| Left|Default 'SO'
Company|5| C| Left| Default Blank
Depot Code|12| C|Right| left pad with blank
Customer Code|9|N| Right|left pad with blank
Out put :--
40000013SO 211 5031JHX400B PKPK 500 041013
You can achieve this just using string.Format(). Take a read of http://msdn.microsoft.com/en-us/library/system.string.format.aspx. If is possible to specify the width of a field and its text alignment, thus allowing you to lay out the fields as per your requirements.
Related
I am using Spire.PDF for .NET to create a pdf file and I am doing the following - take the user input from a field in a webform; this input is normally a numbered list of items as shown here
In the PDF template that will be filled out by my application, there is a multiline text field that will get the text entered by the user as you see above.
Here is how that field looks in the PDF template:
Is it possible to have a number of lines in the target PDF created depending on the number of items in the numbered list entered by the user ? Like in the given example, have 3 lines, each item on its own line, like here:
This would obviously then need to move down other items/artefacts that come after in the PDF automatically (if this list gets significantly longer). Is this possible with this library?
hope you guys can help!
I am trying to create .csv out of Excel which would have columns A - H filled with some data I want to read but data is optional. So some times the first column A can be empty. Now, when I save the .csv, unless I entered one space in the A column, Excel automatically trims A column, and the result is 7 cells to read A - G instead 8 cells A - H (with A column) being "empty". I would like to save client the trouble of needing to enter one space or -> ="" in the Excel formula to make first or last column "empty" but not trimmed in the resulting .csv.
Thank you!
There is no option in Excel to preserve empty columns, when exporting to .csv. But you could introduce a header text in the first row, so you will always have the columns filled atleast with the header text.
Plus it would make your data probably more readable, depending on what data this is.
Another possibility would be to implement a makro and embedd a button in your excel file:
see
how not to skip empty first cell when saving as .CSV?
i have a txt file with format
10000025|246|31032017|00|0|0.00|0.00|0.00|0.00|0|0.00|0.00|0.00|0.00|0.00|0.00|0.00|R
10000025|246|31032017|01|0|0.00|0.00|0.00|0.00|0|0.00|0.00|0.00|0.00|0.00|0.00|0.00|R
10000025|246|31032017|02|0|0.00|0.00|0.00|0.00|0|0.00|0.00|0.00|0.00|0.00|0.00|0.00|R
10000025|246|31032017|03|0|0.00|0.00|0.00|0.00|0|0.00|0.00|0.00|0.00|0.00|0.00|0.00|R
i want import to access database using C# code
If someone has a clue about how to perform something like this, i would be grateful !
I dont think there is any need to use c# sort of thing in this scenario. You can accomplish this task by using an excel sheet. Copy the whole txt file and paste it into the excel sheet, once done Select the header of the cell in which you copied the text (Lets say 'A'). Now in the top menu navigate to Data Tab and select "Text to Columns". A dialogue will appear where you can select Delimited (which is default selection) and click next there you will find the delimiters section where you can specify your delimiter like comma, semi colon, etc. In your case the separator is pipe character '|' so you can specify the pipe character in a text box given in the delimiter list.
Once done click next and finish you will get the data in a column and row form exactly what you were looking for now you can import the data to sql, access or to what ever you want take a look at this Link to know how to import data from excel to access
I am attaching following screen shots
Picture of text data being copied in excelwith header selected
Screen shot of delimiter screen where you will specify the pipe character
I'm having a stored procedure that returns printed text. E.g
To import this report into Excel (and preserve leading zeros in numbers, etc):
Click here, then press CTRL-A, CTRL-C.
Open Excel, press CTRL-A, right-click mouse, select Format Cells, click Text.
Click on A1 cell, press SHIFT-INS to paste.
REPORT FOR 21-09-2013
Date Who Total
21-09-2013 ALBERT 10
So i want to be able to retrieve this text from my C# application. I've tried to retrieve it via ExecuteScalar() and ExecuteReader() but no luck. Is there any other alternative to solve this problem ?
I created csv file in format "Surname;Birthday;Name". Where Birthday is in format ddmmyyyy (e.g. 01121989 or 09111983).
When I opened it in Excel It did not show first '0'.
Can I escape this symbol to show full date in Excel?
When I saved this file from Excel using option "Save as" It lost first '0' in Birthday. Is it possible to prevent this?
Thank you.
In stead of opening the csv as you normally would use a data connection.
For this go to your ribbon item Data > From Text
Browse to your CSV and select Open. Now you will get a text-to-columns window where you can set the specific column properties to Text (so not General or Number). This way the complete set of characters are available.
Once you open the file, right-click the column letter (e.g., B) and select Format Cells. Then choose Custom, and set the format to 00000000. This will add the leading 0 to all cells where it is missing, and when you save it as .csv, it will export the leading 0 in the output file too.
This is typical Excel. You can consider using single quotes:
A,'01121989',B
If you are using a program to read this file you can clear these single quotes easily.
Format your date cells as Text.
Right-click, Format Cells, under Category select Text.
Normally, when you enter some number in Excel, you will see it aligns right, if you enter the same numbers in a Text formatted cell, it will align left, and any zeroes at the starts will be kept.