I am developing an Excel Add-In that extracts the text of cell A1 INCLUDING its format and display the text in its own area. So the add in contains this (see screenshot below): • Area to display the formatted text • Button to start the extraction Please Click to view image
bellow is the code that i am using to get the text
function displaySelectedCells() {
Office.context.document.getSelectedDataAsync(Office.CoercionType.Text,
function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
showNotification('The selected text is:', '"' + result.value + '"');
} else {
showNotification('Error', result.error.message);
}
});
}
The above code is using "CoercionType" as "Text" . I have tried a lot to find the solution to get the text as formatted written in a Sheet Cell. The Response i am getting is plane text only :( Please help me to solve the probelm
To add to Michael Saunder's answer: while you can use myRange.format.font.load(['bold','color','italic','name','size','underline'])
, this will only get you the font, bold, italic, etc. if the formatting is consistent within the cell and in the entire range represented by the myRange object. Since you're only looking for a single cell's format, it doesn't sound like the latter applies to you (it's only a single cell), but the example image you have shows different words within the cell having different bold, italic, color, and so on. With the current APIs you will not be able to get this information.
It sounds like what you're asking is some sort of HTML or image-like representation of the cell. I encourage you to file this as a suggestion on our UserVoice (https://officespdev.uservoice.com/), along with a description of real-world the use-case that you need this for.
~ Michael Zlatkovsky, developer on Office Extensibility team, MSFT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With