Excel Doc after c# modifications: Ctrl + DownArrow is not working properly - c#

guys!
After I create Excel document in my c# application the Ctrl+DownArrow combination doesn't work properly.
It goes to the last row in the current column. So looks like it means all sheet as one data region WITHOUT empty cells.
so I guess empty cells in my excel sheet aren't empty for Excel.
How to figure it out?
Thank you,

Try creating a macro of what you want to happen. Then look at the macro code which is based off of interops calls. See if it sheds a light on your issue and how to resolve.

Just filter out the "Blanks" Ctrl+Down Arrow and all the blank cells would be selected, now press delete (From key board).
DONE. Now you can jump between entries with Ctrl+Down Arrow.

Related

Write to an Excel file while it's open

I'm developing a WindowsForm application where I am storing an accumulator on a destinated variable. Actually, my code is working but what I want to do now is to see the accumulator integer on an Excell cell in real-time.
So I would like to know if there is a way to write/export values from my Form to my Excel file while it is open. The idea is to see the cells being refreshed every time I send the data.
Actually, I am storing the values but with the only condition that the file is closed, so I'm curious if this is possible?
This are the actual lines of code that I have:
SLDocument sl = new SLDocument (#"D:\Excel.xlsx"); sl.SetCellValue("A2","Accumulator");
sl.SetCellValue("A3", myaccumulator);
sl.Save();
I just fixed the problem in case that one of you want to handle with data as this way, i just created other File and programmed a Macro with vba to export the data of the closed File, so now I can see the cells being refreshed every time with one Click button.
Thanks for your help, regards to everyone.

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.

Hyperlink within a OpenOffice calc using c#

I've made a spreadsheet in openoffice using c# with several different sheets. On sheet 1 is a list of all the names of the rest of the sheet. how is it possible to set up a hyperlink from each of these cells to there corresponding sheet.
I have looked through the internet but i have struggled to find any helpful information. Can anybody point me in the right direction on how to program this?
I'm not sure if i understand you right, but this may be helpful, put it in your cell:
=HYPERLINK("MyTableName.C3")
This (should) jump to cell C3 in table MyTableName.
To just jump to a table use
=HYPERLINK("#MyTableName")
I cannot try it because i don't use OpenOffice
Source: http://www.ooowiki.de/HyperLink

How to Insert Values in Specific Excel Cells From DataGridView

Can you please help me to figure out how I can insert DataGridView values into a pre defined excel template (Into Specific Cells)?
I have a DataGridView on my windows Form which is getting the values from user input. Now I would like to enable users to export the DataGridView values into an excel file (A File like attached excel file).
As far as I know I have to create the headers and add them to the code programmatically but for the DataGridView part, honestly I have no idea how I can do that?
As you can see the Form (Box) is starting from B2 to K2 and end from B21 to K21 Now my question is how i can start importing values from B4 - k4 and so on?
Is there any way I can format the style of the cell (like Background color or font style and size) from C#? I mean generating a form like what is looking in attached Excel programmatically.
Thanks for your time in advance
Not sure if this is what you're looking for but ff you are using Office Interop, you can insert a 2-dimensional array into a range in Excel.
The following snippet might not be correct (no VS nearby and I haven't used excel automation for a long time) but you'll get the picture.
Excel.Range oRange = oSheet.Range("B2",Missing.Value);
oRange.Resize(myArray.GetLength(0),myArray.GetLength(1));
oRange.Value = myArray;

Excel: Ctrl + DownArrow action

Anybody please tell me which action program does when I click CTRL+↓ hotkey?
I know that program navigates down to the next non-empty cell. But when I create Excel document from Excel.Interop the CTRL+ ↓ doesn't work like it have to. It navigates to the last cell in the column...
Any help is greatly appreciated.
UPDATE: I'm sorry for being not so clear. I don't care about CTRL+↓ behaviour actually. I'm concerning about what causes data acting like one big cell?
Jeffrey,
Not sure what you mean by, "acting like one big cell". If you want to get the entire used area of a sheet, used the property UsedRange on the Worksheet object. It will return a two-dimensional array of the used range for that Worksheet. I've used it when a Worksheet contained all the data in a table. Much easier than iterating the Worksheet.
Cheers!

Categories