Delete Existing Ranges in Excel Open XML - excel

I'm working with the Open XML SDK to create an Excel document. To save time, I start with an existing document, and just make the changes I need.
To locate certain cells, my existing document defines a number of ranges. However, when I'm done I'd like to remove those ranges.
I can't seem to find any way to remove ranges from an Excel document that already has them. Any tips, suggestions or links?

Ranges are stored as defined names under the workbook element. You will need to find the defined name element based on the name you gave it in the worksheet and then delete it that way.
public void DeleteRange(WorkbooPart workbookPart, string definedNameToDelete)
{
workbookPart.Workbook.DefinedNames.Descendants<DefinedName>().First(x => x.Name == definedNameToDelete).Remove();
}
This is just a quick snippet of what you might have to do. Obviously, you might need error checking if the DefinedNames element doesn't exist or the defined named you want to delete has already been deleted, but hopefully this will point you in the right direction.

Named ranges are defined in workbook.
Look at it's api and try finding it there. Or check out MSDN.
Also, take a look at Templater. Maybe it already does what you need. Disclamer: I'm the author.

Related

How do I use Office.JS to add invisible information to a cell in Excel?

I need to add some information to an Excel cell or the same information to several selected Excel cells and that information should not be visible. How is this possible? I know I could add something to the properties of the whole worksheet, using the addresses (e.g. "Sheet1!A1") of the cells, but then when the table changes, the information is no more correct. I also thought I could use addFromSelectionAsync, but did not manage to use it, I think addFromSelectionAsync is not the right tool. I have seen that other AddIns are producing something like the follwoing (in different files in the saved Excel document): [UPDATE: this is not the way to go, see my second comment below]
<x15:webExtensions xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
<x15:webExtension appRef="{12345678-...}">
<xm:f>Sheet1!$A$1</xm:f>
</x15:webExtension>
<x15:webExtension appRef="{ABCABCAB-...}">
<xm:f>Sheet1!$A$2</xm:f>
</x15:webExtension
</x15:webExtensions>
<we:bindings>
<we:binding id="BINDING-ID-1" type="text" appref="{12345678-...}"/>
<we:binding id="BINDING-ID-2" type="text" appref="{ABCABCAB-...}"/>
</we:bindings>
and then use <we:properties> (I think) to know which binding-IDs are used. Is this the way to go, will the values in <xm:f> automatically be updated, and how do I do this in code?
Thanks in advance.
The first part was already resolved see my old comments above:
addFromPromptAsync, using the information I want to save as the ID, adds the <x15:webExtension> and the according <we:binding>.
I am now using a UUID as the value in addFromPromptAsync, and setting the actual value via Office.context.document.settings.set with key = the UUID and value = the actual value.
It was then my question:
given a cell (i.e. the accordings range) I cannot get the IDs of the according bindings
For this second part of the problem, I added event handlers via binding.addHandlerAsync for the relevant Binding-IDs. Those event handler can read the binding ID from the event data.
So my problem is resolved, since I only need the Binding ID when the according cell is selected.
There is still the problem that I need to unset the binding ID that I save in a variable when another cell without that data is selected, I am using a timestamp for this, >200ms after the last binding selection event, selecting another cell deletes the info. Cf. my question Can I set an order for the Event Handlers in Office.JS? for that last point.

Adding Entry to Table - Adding onto Existing Entry

I am trying to figure out a way to add data to an existing table, where it can identify a value (like name or ID#) and add in a new piece of data into that row for the individual.
See Pic 1: The person using this guide will click "yes" or "no" if they want to move the person forward. I want to record that yes/no in their database. (Note: each new candidate gets their HR Guide with their name on it. If you are listed on the Short list (see pic 2), you will get a HR Guide created for you. So the name of the tab is unpredictable, which is why things like vlookups or other formulas will not work.)
Here is the image of where I want the input to go. Based on the name matching in column C, I want it to input the Yes/No in Column I
I have no VBA code to share as I have no clue where to start. I have looked around trying to find a solution or something to work off of, but cannot find something that is close enough for me to figure it out (usually that works for me, but not this time...). So any help/direction you can provide would be VERY helpful! Thanks in advance.

Changing Referenced Cell when Cell with Reference is changed

I honestly didn't know how else to word that title, but what I'm wanting to know if it's possible is to be able to have many sheets that represent data, and have a front page that looks up the needed values, but allows you to change the referenced values by changing the cell that is displaying, basically like you would be able to do with an object reference in Java, where you could create a new variable with the original object, but changes to the new variable would change the original object.
If it requires VBA, I'll likely just make a quick mobile or web-mobile app to do the same thing. I just wanted to know if it was possible, since the entire thing is already in Excel, and I didn't even know what terminology to search for to find it on my own.

autoCrat naming google documents

Can autocrat be set up to use a column heading to name the document when it is merged. I have a form that creates student information and final grades in a spreadsheet and I use autocrat to merge data from the spreadsheet to a google doc., but each document merged has the same name unless I change it in the merge process or after the merge is complete. It seems if we could use <<Student>> in the "File naming convention to use" in the Set merge type step this would solve the problem.
If I got it right, you just have to use the proper tag at the fifth step of autocrat configuration. It'll probably be something like $student.

SharePoint Web Parts can not be connected via hyperlink fields

In short:
I'm trying to filter an XSLTListViewWebPart based on what is selected in another XSLTListViewWebPart. Using a String field as connection this is working fine. Using a hyperlink field no data is displayed.
In more detail:
I have two lists, say Accounts and Projects. Both have a hyperlink field accountURL.
All accounts have different accountURLs. Different projects can have the same value for accountURL. Both are displayed on a page using the XSLTListViewWebPart.
The simple goal is to filter the Projects list based on which item is selected in the Accounts list using the accountURL field. So I established a web part connection using the acountURL as a filter. Alas, when an item in the Accounts list is selected no items are showwn in the Projects list although I double checked that there are matching values.
When using a string field instead of a hyperlink field for accountURL everything works like a charm. Problem is, I need the hyperlink field.
Is this desired behaviour? Do you have any suggestions for a workaround?
(I already tried converting the hyperlink field to a string field via a calculated column which did not work out either.)
All was and is to be done in the web interface or SP-Designer. Coding a WSP is not an option for this problem. As I'm not quite familiar with the correct terminus technicus I use field and column interchangeably.
All help is greatly appreciated.
Ben
Someone on the Microsoft forum suggested the following workaround which does its job well:
Add a hidden text column to both lists.
Use a workflow which is triggered on item creation and update to copy the value of the hyperlink column to the hidden text column.
Connect both webparts using the hidden column as filter.
Nonetheless, I still wonder whether it is possible to use hyperlink columns or other special columns for filtering. I also had the problem that I cannot use a person column as lookup.
Does anyone know if whether there ist some kind of overview
which column types can be used for filtering/formulas/lookup/...?
Cheers,
Ben

Resources