Skip to content

[excel, powerpoint] (Create Workbook/Presentation) Update code samples to avoid casting #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/excel/44-shape/shape-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ script:

reader.onload = (event) => {
Excel.run((context) => {
const startIndex = (<string>(<FileReader>event.target).result).indexOf("base64,");
const mybase64 = (<string>(<FileReader>event.target).result).substr(startIndex + 7);
const startIndex = reader.result.toString().indexOf("base64,");
const mybase64 = reader.result.toString().substr(startIndex + 7);
const sheet = context.workbook.worksheets.getItem("Shapes");
const image = sheet.shapes.addImage(mybase64);
image.name = "Image";
Expand Down
4 changes: 2 additions & 2 deletions samples/excel/50-workbook/create-workbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ script:
reader.onload = ((event) => {
Excel.run(context => {
// strip off the metadata before the base64-encoded string
const startIndex = (<FileReader>event.target).result.indexOf("base64,");
const mybase64 = (<FileReader>event.target).result.substr(startIndex + 7);
const startIndex = reader.result.toString().indexOf("base64,");
const mybase64 = reader.result.toString().substr(startIndex + 7);

Excel.createWorkbook(mybase64);
return context.sync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ script:
reader.onload = (event) => {
Excel.run((context) => {
// strip off the metadata before the base64-encoded string
const startIndex = (<string>(<FileReader>event.target).result).indexOf("base64,");
const workbookContents = (<string>(<FileReader>event.target).result).substr(startIndex + 7);
const startIndex = reader.result.toString().indexOf("base64,");
const workbookContents = reader.result.toString().substr(startIndex + 7);

const sheets = context.workbook.worksheets;
sheets.addFromBase64(
Expand Down
4 changes: 2 additions & 2 deletions samples/excel/99-just-for-fun/tetrominos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ script:
const reader = new FileReader();

reader.onload = (event) => {
const startIndex = (<string>(<FileReader>event.target).result).indexOf("base64,");
const mybase64 = (<string>(<FileReader>event.target).result).substr(startIndex + 7);
const startIndex = reader.result.toString().indexOf("base64,");
const mybase64 = reader.result.toString().substr(startIndex + 7);
backgroundPicture = mybase64;
};

Expand Down
4 changes: 2 additions & 2 deletions samples/powerpoint/basics/create-presentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ script:

reader.onload = (event) => {
// strip off the metadata before the base64-encoded string
const startIndex = (<string>(<FileReader>event.target).result).indexOf("base64,");
const copyBase64 = (<string>(<FileReader>event.target).result).substr(startIndex + 7);
const startIndex = reader.result.toString().indexOf("base64,");
const copyBase64 = reader.result.toString().substr(startIndex + 7);

PowerPoint.createPresentation(copyBase64);
};
Expand Down
8 changes: 4 additions & 4 deletions snippet-extractor-output/snippets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2699,8 +2699,8 @@ Excel.ShapeCollection.addImage:

reader.onload = (event) => {
Excel.run((context) => {
const startIndex = (<string>(<FileReader>event.target).result).indexOf("base64,");
const mybase64 = (<string>(<FileReader>event.target).result).substr(startIndex + 7);
const startIndex = reader.result.toString().indexOf("base64,");
const mybase64 = reader.result.toString().substr(startIndex + 7);
const sheet = context.workbook.worksheets.getItem("Shapes");
const image = sheet.shapes.addImage(mybase64);
image.name = "Image";
Expand Down Expand Up @@ -3276,8 +3276,8 @@ Excel.WorksheetCollection.addFromBase64:
reader.onload = (event) => {
Excel.run((context) => {
// strip off the metadata before the base64-encoded string
const startIndex = (<string>(<FileReader>event.target).result).indexOf("base64,");
const workbookContents = (<string>(<FileReader>event.target).result).substr(startIndex + 7);
const startIndex = reader.result.toString().indexOf("base64,");
const workbookContents = reader.result.toString().substr(startIndex + 7);

const sheets = context.workbook.worksheets;
sheets.addFromBase64(
Expand Down