2016-11-26 1 views
0

OneNote 추가 기능에 대한 설명서에는 표 셀을 가져 오는 방법이 나와 있습니다. 아래 코드 스 니펫 (문서의 예에서 약간 수정)에서 [0,0] 위치에 표 셀을로드합니다. 그러나 일단 TableCell을 얻으면 내용을에로드하는 방법이 불분명합니다. TableCell의 인테리어가 무엇인지 어떻게 알 수 있습니까? 할 일이 있습니까OneNote 추가 기능 : TableCell의 내용

var cell = table.getCell(0,0); 
cell.getContents();//Is this correct? 

내부 내용이 알려지지 않았기 때문에 패턴을 생각하는 올바른 방법이 아닙니까?

감사합니다.

답변

1

OneNote.run(function(ctx) { 
 
\t var app = ctx.application; 
 
\t var outline = app.getActiveOutline(); 
 

 
\t // Queue a command to load outline.paragraphs and their types. 
 
\t ctx.load(outline, "paragraphs, paragraphs/type"); 
 

 
\t // Run the queued commands, and return a promise to indicate task completion. 
 
\t return ctx.sync().then(function() { 
 
\t \t var paragraphs = outline.paragraphs; 
 

 
\t \t // for each table, append a column. 
 
\t \t for (var i = 0; i < paragraphs.items.length; i++) { 
 
\t \t \t var paragraph = paragraphs.items[i]; 
 
\t \t \t if (paragraph.type == "Table") { 
 
\t \t \t \t var table = paragraph.table; 
 
\t \t \t \t var cell = table.getCell(0,0); 
 
\t \t \t \t //To do - how to get value inside? 
 
\t \t \t } 
 
\t \t } 
 
\t \t return ctx.sync(); 
 
\t }) 
 
}) 
 
.catch(function(error) { 
 
\t console.log("Error: " + error); 
 
\t if (error instanceof OfficeExtension.Error) { 
 
\t \t console.log("Debug info: " + JSON.stringify(error.debugInfo)); 
 
\t } 
 
});

테이블 셀에 대한 공식 문서를 참조하십시오 이 https://github.com/OfficeDev/office-js-docs/blob/master/reference/onenote/tablecell.md

테이블 셀은 단순히 단락이 포함되어 있습니다. 이러한 단락은 richtext, 이미지, 개요 또는 tablerows 및 tablecells가있는 또 다른 테이블 일 수 있습니다.

테이블 셀 안에 무엇이 있는지 알아 보려면 해당 유형의 하위 단락을로드 한 다음 해당 유형에 따라 하위 단락 속성을로드해야합니다 (코드에서와 같은 방식으로).