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!
Related
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.
I stated the question above the way I did, because I can already do the following, and it doesn't give me the solution I need.
I can:
Get the number of pages per sheet
Get the last USED row on any given SHEET (not per printed page, so that doesn't help)
I can find out if manual or automatic page breaks have been inserted
(just not WHERE)
And that's what I need: To know the number of the row for each page break on any given sheet. Some sheets have 1 page, some have 100.
I need to do this because I need to put something at the bottom of each page, however, the number of pages per sheet is not static. Some sheets have been set to landscape, others to portrait. Some sheets have the "Put all columns on one page" option set, which CHANGES the number of rows on that page.
PLEASE NOTE: The solution to this problem is not "Use the footer", as the footer will not accept the data that I need to put on each page.
I also cannot statically decide the number of rows each page type might have -- I let Excel decide that when I set the orientation.
I've been looking for several days now, and I have been unable to find how to determine what the last row on a printed page will be.
I'm using office and VS 2010 and I'm using the office interop. I'm not posting much code because I have no idea what to use at this point. However, it is safe to say that to access any given worksheet I'm using the following code:
Excel.Application excelApp = new Excel.Application();
Excel.Worksheet workSheet;
I'd be willing to bet that there's a very simple way to do this, and I just haven't hit across the right combination of google search terms. But it's been a few days now, so I thought I'd post something here. Thanks for any help.
I don't think you have a way to calculate that on your own... It is very complicated, because the number of rows on each page depends on many variables (Printer page size, orientation, zoom level, etc.).
You can try to use this: Repeat specific rows or columns on every printed page
How do ranges and selections work?
If you insert something at the top of the page through a range, is that overridden by inserting something with selection? Does selection affect ranges?
I'm having a problem where I do inserts in this order, but the InlineShapes show up at the top of the document above the Range.Inserts. Also, the Selection.InsertBefore gets replaced by the InlineShapes.
I would like my range insert to appear above each picture, like a heading. How can this be done?
Selection.InsertBefore
**Loop**
Range.InsertParagraphAfter
Selection.InlineShapes.AddPicture
**End Loop**
I've asked a question like this three times now with no responses. Anything would help!
EDIT:
I'm a step closer. Now, when I add my InlineShapes, I use Content.InlineShapes.AddPicture(FileName: x, range: y). Now the pictures are showing up in between paragraphs, but they are in the first cell of a table I add to the document before adding the picture. I add the table with with a collapsed range.
You write:
I've asked a question like this three times now with no responses. Anything would help!
And for reference, the questions referred to (I guess) are:
How to add items one at a time to to a new line a word document using word interop
Using interop.word ranges
... which all now have been answered :)
You ask multiple questions in this post however - first:
How do ranges and selections work?
Actually, the documentation covers this quite well:
A range:
"Represents a contiguous area in a document.
Each Range object is
defined by a starting and ending character position. Similar to the
way bookmarks are used in a document, Range objects are used to
identify specific portions of a document..."
Reference: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.range(v=office.14).aspx.
If you insert something at the top of the page through a range, is
that overridden by inserting something with selection?
It can be. This depends on what has been selected. If you select something that intersects with the range of the content you just inserted and changes the content, then you will make changes to the content of the range.
To understand this completely, I will recommend that you read about:
The Selection Interface
The Range Interface
Does selection affect ranges?
It depends. The documentation states:
Range objects are independent of the selection.
Reference: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.range(v=office.14).aspx
... so if you just do a simple selection in order to, e.g., read content or copy content to
the clipboard, nothing would change. However, if you use the selection to change content, of course this would affect the content pointed to by the ranges. In continuation of this you should note that MS recommends using Range objects for document manipulation:
Because Range objects share many of the same methods and properties as
Selection objects, using Range objects is preferable for manipulating
a document when there isn't a reason to physically change the current
selection.
Reference: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.selection.aspx
And finally, you ask:
I'm having a problem where I do inserts in this order, but the
InlineShapes show up at the top of the document above the
Range.Inserts. Also, the Selection.InsertBefore gets replaced by the
InlineShapes.
I would like my range insert to appear above each picture, like a
heading. How can this be done?
See my previous answer to your question: " How to add items one at a time to to a new line a word document using word interop " here: https://stackoverflow.com/a/12751805/700926 - that gives you a complete answer.
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
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.