I am trying to find the displayed cell area for an embedded Excel object in word.
I have attached a wordfile containing an Excel object. How do I find the displayed Cell-range?
I have extracted the Excel file as flw:
var doc = new Aspose.Words.Document(file);
var sec = doc.Sections[0];
var body = sec.Body;
var paragraph = body.LastParagraph;
foreach (var cNode in paragraph.ChildNodes)
{
var shape = cNode as Aspose.Words.Drawing.Shape;
if (shape==null) continue;
if (shape.OleFormat == null) return;
if (!shape.OleFormat.ProgId.StartsWith("Excel.Sheet")) return;
if (shape.OleFormat.IsLink) return;
var mem = new MemoryStream();
shape.OleFormat.Save(mem);
mem.Seek(0, SeekOrigin.Begin);
var wkBookEmb = new Aspose.Cells.Workbook(mem);
var sheet = wkBookEmb.Worksheets[wkBookEmb.Worksheets.ActiveSheetIndex];
<span style="color: green;">// Find displayed cell-range ???</span>
}v</pre>
Hi Bent,
Thanks for your inquiry. Your query is more related to Aspose.Cells team. I am moving this thread to Aspose.Total forum. My colleagues from Aspose.Cells team will reply you shortly.
Hi,
I would like to discuss the matter/issue regarding Aspose.Cells.
Well, if you need to find the complete data range in the Excel sheet , you may do it by using the sample line of code:
E.g
Sample code:
Aspose.Cells.Range sourceRange = sourceSheet.Cells.MaxDisplayRange;
Aspose.Cells.Range destRange = destSheet.Cells.CreateRange(sourceRange.FirstRow, sourceRange.FirstColumn, sourceRange.RowCount, sourceRange.ColumnCount);
Also, I am not sure about your mentioned CellRange displayed in the embedded Excel object. If you need to get the displayed range shown in the ole object in word document, this cannot be possible as after you have already inserted Excel object into MS Word as Ole object, we have no control over the Word document's Ole Object once it is shown/inserted in a word file.
Thanks for your understanding!
The embedded Excel in Word may contain a lot of cells, but only a few of them may be visible in the Frame containing the Excel Ole object. Are you saying that it is not possible to get information from either Word or the Extracted Excel-file (=ole object) about witch cell is displayed in the upper left corner in the window in word?
Brgds
Hi,
Yes, I mean it for Aspose.Cells, Aspose.Cells is a spreadsheet management library to work with Excel files, it cannot load Word file, so it cannot get the embedded ole object inside a word document.
Thanks,