Add "Edit in Excel" or "Edit Photo" Extension

Is it possible to add a logo or other picture in an Excel sheet and lock its position on the sheet?

Not really a programming question but the way to do this is...

Right click the image and choose Size and Properties.
Click Properties tab and under properties,(optional- choose Don't move or size with cells) and ensure the Locked box is checked.

Highlight the cells of the worksheet you want the users to be able to edit, right click inside one of them and choose Format Cells. In the protection tab uncheck the locked checkbox.

Then you can protect the worksheet. Click Home, then Format, then Protect Sheet.
Make sure you unselect Select locked cells, leave the top checkbox selected (Protect worksheet and contents of locked cells) as well as select unlocked cells checked.

How to add the project prefix file to photo extension target?

You can change your extension's prefix header by changing your project's build settings. First, open the main project window in Xcode and select your photo extension target from the list on the left. Go to Build Settings -> Apple LLVM 6.0 - Language, then set Precompile Prefix Header to Yes and Prefix Header to your prefix header's path (you can copy this from the corresponding settings in your main application target). If you can't see these options, make sure All is selected at the top of the window instead of Basic.

Editing an Excel Object embedded in a Word document in Excel

You could try a way I prorosed here:

How to insert an Image in WORD after a bookmark using OpenXML.

In short, use Open XML SDK 2.0 Productivity Tool (which is a part of Open XML SDK 2.0). Do whatever you need to do with document manually in MS Word. Then open this file in Open XML SDK 2.0 Productivity Tool. Then find the edits you are interested in to see how it is represented in OpenXML format , as well as how to do that programmaticaly.

Hope that helps!


UPDATED:


Okay - I have got better now what's the problem is... So in addition to my advice above I would recommend you to look at this threads on MSDN Forum:

  • How to modify the imbedded Excel in a Word document supplying chart
    data
  • Embedded excel sheet in word

I let myself to repost the code sample (posted on MSDN Forum by Ji Zhou) just to avoid the deletion of original thread there.

Hope it is helpful enough to retrieve the Excel object from Word, change some cells and embed it back into Word.

public static void Main()
{
using (WordprocessingDocument wDoc = WordprocessingDocument.Open(@"D:\test.docx", true))
{
Stream stream = wDoc.MainDocumentPart.ChartParts.First().EmbeddedPackagePart.GetStream();
using (SpreadsheetDocument ssDoc = SpreadsheetDocument.Open(stream, true))
{
WorkbookPart wbPart = ssDoc.WorkbookPart;
Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().
Where(s => s.Name == "Sheet1").FirstOrDefault();
if (theSheet != null)
{
Worksheet ws = ((WorksheetPart)(wbPart.GetPartById(theSheet.Id))).Worksheet;
Cell theCell = InsertCellInWorksheet("C", 2, ws);
theCell.CellValue = new CellValue("5");
theCell.DataType = new EnumValue<CellValues>(CellValues.Number);
ws.Save();
}
}
}
}

private static Cell InsertCellInWorksheet(string columnName, uint rowIndex, Worksheet worksheet)
{
SheetData sheetData = worksheet.GetFirstChild<SheetData>();
string cellReference = columnName + rowIndex;
Row row;
if (sheetData.Elements<Row>().Where(r => r.RowIndex == rowIndex).Count() != 0)
{
row = sheetData.Elements<Row>().Where(r => r.RowIndex == rowIndex).First();
}
else
{
row = new Row() { RowIndex = rowIndex };
sheetData.Append(row);
}
if (row.Elements<Cell>().Where(c => c.CellReference.Value == columnName + rowIndex).Count() > 0)
{
return row.Elements<Cell>().Where(c => c.CellReference.Value == cellReference).First();
}
else
{
Cell refCell = null;
foreach (Cell cell in row.Elements<Cell>())
{
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
{
refCell = cell;
break;
}
}

Cell newCell = new Cell() { CellReference = cellReference };
row.InsertBefore(newCell, refCell);
worksheet.Save();
return newCell;
}
}

Insert picture into Excel cell

You can add the image into a comment.

Right-click cell > Insert Comment > right-click on shaded (grey area) on outside of comment box > Format Comment > Colors and Lines > Fill > Color > Fill Effects > Picture > (Browse to picture) > Click OK

Image will appear on hover over.

Microsoft Office 365 (2019) introduced new things called comments and renamed the old comments as "notes". Therefore in the steps above do New Note instead of Insert Comment. All other steps remain the same and the functionality still exists.


There is also a $20 product for Windows - Excel Image Assistant...



Related Topics



Leave a reply



Submit