How to not skip empty cell in Excel when creating .csv file - c#

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?

Related

OLEDB C# Update and Insert data [duplicate]

I would like to type at least 500 characters in excel sheet cell. But when I do that it only lets me add 1 paragraph like 196 characters. When I add another paragraph, it gives me a message **
"Exceeded Text Limit"
**. How do I resolve this so I can add lot of text in the cell. I googled and tried different things and failed.
Please help !!!
There is a 32,767 character limit in Excel per cell when wrapping text.
You might be able to import it into Access as a Table, with a Memo field that can hold 65,000 characters.
A text box can also hold more, but if you're doing any calculations, this isn't practical.
Try looking here: http://excel.tips.net/Pages/T003163_Character_Limits_for_Cells.html

No separation between column headers and first row of data

I have a list view in WinForms that works and looks fine. However, the grid lines are formatted in such a way that there's no separation between the column headers and the first row of data. This makes it look like the first row of data is part of the column headers. You can see what I mean here:
Is there any way I can format the list to stop this from happening, and make it look 'proper'? Thanks for any help.
I see you're displaying "data" to users in a grid - except you're using a ListView - which is really intended for filesystem display, not data.
I recommend you switch to using DataGridView (avoid System.Windows.Forms.DataGrid as it's older and doesn't let you (easily) control the data being displayed).
Also, protip for usability: if a table cell contains numeric data then it should be formatted with Right alignment, otherwise give it a Left alignment - avoid Middle/Center alignment in non-header table cells as it makes it difficult to visually scan a table.

Excel cell formula is updating with sheet name. Exporting from ASP.NET

=CONCATENATE( "Level3!$B", MATCH($B6,Level31!$A:$A,0),":$B", COUNTIF(Level31!$A:$A,$B6) + MATCH($B6,Level31!$A:$A,0)-1)
I have this formula in excel cell. Which I am copy pasting in all the rows below through C# code. It is fine till here.
The problem is that in this formula Level3 was a sheet name which is renamed to Level31. This change is reflecting in formula automatically in three places and not on first place..Why
After manual formula update in cell it works fine.
Second problem is in next cell
where another formula is implemented. When I am opening sheet it shows #N/A
but when I click in the cell and hit enter key. It starts working..
Can anyone please guide me?
If you are referring to first place as =CONCATENATE( "Level3!$B", , that value is stored as string and will not automatically adjust from 3 to 31. Try this formula =CONCATENATE(MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)&"!$B", MATCH($B6,Level31!$A:$A,0),":$B", COUNTIF(Level31!$A:$A,$B6) + MATCH($B6,Level31!$A:$A,0)-1)
formula MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255) makes your first place also dynamic.

Import Txt file to access database

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

How to paste multi-lined and tabulated text into DataGridView?

I'm trying to copy and paste Multi-lined and tabulated DataGridView cell strings into other cells (DataGridViewTextBoxColumn). For example I would like to copy one column of text into another column. The problem I encounter is that the single cell can contain multi-lined and tabulated text which makes it imposible to distinguish between DataGridView rows and columns. Any ideas how to accomplish this?
If you mean 'distinguish visually', try changing the AlternatingRowsDefaultCellStyle background color to something else. This should distinguish the rows.
Also, if you set DefaultCellStyle.WrapMode to False it will display the multilined strings nicely.
So, what exactly are you trying to accomplish? Copying from one cell to multiple cells could be done by dividing between multiple entries. Whatever way you want to go, you have to achieve some clearance on how and where to seperate the data.

Categories