本文整理汇总了TypeScript中file-saver.saveAs函数的典型用法代码示例。如果您正苦于以下问题:TypeScript saveAs函数的具体用法?TypeScript saveAs怎么用?TypeScript saveAs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了saveAs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: if
return this.betterdb.getExcel(loggedin).subscribe(data => {
//console.log(`downloading data`)
const content = data.headers.get("content-disposition")
const blob = data.body
if(content && blob){
const filename = content.split(" ")[1].split("=")[1]
FileSaver.saveAs(blob, filename, true)
} else if(blob) {
this.snackBar.openFromComponent(ToastComponent, { data: { message: "wrong filename, will not verify", level: "warning"}})
FileSaver.saveAs(blob, "bets.xlsx", true)
} else {
this.snackBar.openFromComponent(ToastComponent, { data: { message: "could not download excel", level: "error"}})
}
},
开发者ID:idot,项目名称:betterplay,代码行数:14,代码来源:statistics.component.ts
示例2: download
download(name?: string) {
var isFileSaverSupported = false;
try {
isFileSaverSupported = !!new Blob();
} catch (e) {
alert("blob not supported");
}
name = (name === undefined)? "trial.svg" : name;
let gnode: any = this.g.node()
var bbox = gnode.getBBox();
var width = this.svg.attr("width"), height = this.svg.attr("height");
this.g.attr("transform", "translate(" + (-bbox.x + 5) +", " +(-bbox.y + 5) +")");
let svgNode: any = this.svg
.attr("title", "Trial")
.attr("version", 1.1)
.attr("width", bbox.width + 10)
.attr("height", bbox.height + 10)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node();
var html = svgNode.parentNode.innerHTML;
html = '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ' + html.slice(4);
this.svg
.attr("width", width)
.attr("height", height);
this.g.attr("transform", this.transform);
if (isFileSaverSupported) {
var blob = new Blob([html], {type: "image/svg+xml"});
fs.saveAs(blob, name);
}
}
开发者ID:gems-uff,项目名称:noworkflow,代码行数:30,代码来源:graph.ts
示例3: exportASM
/**
* Compile current document and export assembly code
*/
exportASM() {
let source = this.currentDocument.editor.content;
let asm = Util.bench('compile', () => this._compiler.compile(source));
let blob = new Blob([asm], { type: 'text/plain;charset=utf-8' });
saveAs(blob, 'Untitled.asm');
}
开发者ID:munshkr,项目名称:gakuon-editor,代码行数:10,代码来源:index.ts
示例4: gpxExport
/**
* Export LatLng coordinates as a GPX file
*
* Stolen from here:
* https://github.com/mstock/osrm-frontend/blob/7bcb1b3587fb502c016daa61eae5270bca6b90bf/src/tools.js
*
* @param {LatLng[]} coordinates
*/
export default function gpxExport(coordinates) {
var trackPoints = coordinates.map(function(coordinate) {
return {
'$lat': coordinate.lat,
'$lon': coordinate.lng
};
});
var gpx = {
'gpx': {
'$xmlns': 'http://www.topografix.com/GPX/1/1',
'$xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'$xsi:schemaLocation': 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd',
'$version': '1.1',
'trk': {
'trkseg': {
'trkpt': trackPoints
}
}
}
};
var gpxData = JXON.stringify(gpx);
var blob = new Blob(['<?xml version="1.0" encoding="utf-8"?>', '\n', gpxData], {
type: 'application/gpx+xml;charset=utf-8'
});
saveAs(blob, 'route.gpx');
}
开发者ID:salomvary,项目名称:outdoormaps,代码行数:36,代码来源:gpx-export.ts
示例5: ensureRendered
ensureRendered(() => {
let rootNode = document.getElementById('nbdime-root')!;
let content = rootNode.outerHTML;
// Strip hover text of CM ellipses
content = content.replace(/title="Identical text collapsed. Click to expand."/g, '');
let blob = new Blob([prefix + content + postfix], {type: 'text/html;charset=utf-8'});
saveAs(blob, 'diff.html');
});
开发者ID:vidartf,项目名称:nbdime,代码行数:9,代码来源:staticdiff.ts
示例6: saveFile
/**
* Saves a file
* @param file
* @param filename
* @param mimeType an optional mime type
*/
public saveFile(file: BlobPart, filename: string, mimeType?: string): void {
const options: BlobPropertyBag = {};
if (mimeType) {
options.type = mimeType;
}
const blob = new Blob([file], options);
saveAs(blob, filename, { autoBOM: true });
// autoBOM = automatic byte-order-mark
}
开发者ID:CatoTH,项目名称:OpenSlides,代码行数:15,代码来源:file-export.service.ts
示例7: serveDownload
/**
* Create a browser file download from the given object.
* It will be served as json file.
* @param {Object} data
* @param {string} filename
*/
private serveDownload(data: object, filename: string) {
fs.saveAs(
new Blob(
[JSON.stringify(data)],
{type: 'application/json'}
),
filename + '.json'
);
}
开发者ID:dArignac,项目名称:treasury,代码行数:15,代码来源:backup.service.ts
示例8: Blob
this.documentService.obtainReport(this.document).subscribe((res: Response) => {
const contentDisposition = res.headers.get('Content-Disposition');
let filename = this.document.documentId + '.pdf';
if (contentDisposition) {
filename = res.headers.get('Content-Disposition').match(/filename=(.*)/)[1];
}
const file = new Blob([res.blob()], { type: res.headers.get('Content-Type') });
saveAs(file, filename);
});
开发者ID:openfact,项目名称:openfact-web-console,代码行数:9,代码来源:view-toolbar.component.ts
示例9: exportSID
/**
* Compile current document and export to .sid
*/
exportSID() {
let source = this.currentDocument.editor.content;
let asm = Util.bench('compile', () => this._compiler.compile(source));
let {objectCode} = Util.bench('assemble', () => this._assembler.assemble(asm));
let sidData = Uint8Array.from(objectCode);
let blob = new Blob([sidData], { type: 'application/octet-binary' });
saveAs(blob, 'Untitled.sid');
}
开发者ID:munshkr,项目名称:gakuon-editor,代码行数:12,代码来源:index.ts
示例10: downloadString
export function downloadString(
fileContents: string,
filepath: string,
contentType: string
) {
const filename = filepath.split("/").pop();
const blob = new Blob([fileContents], { type: contentType });
// NOTE: There is no callback for this, we have to rely on the browser
// to do this well, so we assume it worked
FileSaver.saveAs(blob, filename);
}
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:11,代码来源:contents.ts
示例11: export
export() {
const data = this.expenses.data;
// console.log(data);
const json = JSON.stringify(data, null, '\t');
const blob = new Blob([json], {
type: 'application/json;charset=utf-8'
});
const filename = 'umsaetze-' + Date.today().toString('yyyy-MM-dd') + '.json';
// console.log(filename);
saveAs(blob, filename);
}
开发者ID:spidgorny,项目名称:umsaetze,代码行数:11,代码来源:sync.component.ts
示例12: exportPlayer
/**
* Compile current document and export player program
*/
exportPlayer() {
let source = this.currentDocument.editor.content;
let asm = Util.bench('compile', () => {
let compiler = new Compiler({ player: true });
return compiler.compile(source);
});
let {objectCode} = Util.bench('assemble', () => this._assembler.assemble(asm));
let prgData = Uint8Array.from(objectCode);
let blob = new Blob([prgData], { type: 'application/octet-binary' });
saveAs(blob, 'Untitled.prg');
}
开发者ID:munshkr,项目名称:gakuon-editor,代码行数:15,代码来源:index.ts
示例13: saveEmbeddedScript
saveEmbeddedScript(templateHtml: string) {
const html = JSON.stringify(`${TPL_CSS}${templateHtml}`);
const script = `(function(w, d, b) {
var tpl = ${html};
d.addEventListener('DOMContentLoaded', function() {
var block = document.createElement('div');
block.innerHTML = tpl;
d.body.appendChild(block);
});})(window, document);`;
const blob = new Blob([script], {type: 'text/javascript;charset=utf-8'});
FileSaver.saveAs(blob, 'poptin-embedded.js');
}
开发者ID:x1unix,项目名称:poptin-builder,代码行数:14,代码来源:templates.service.ts
示例14: saveAs
.then((blob) => {
saveAs(blob, `${this.project.name}-${Date.now()}.zip`);
});
开发者ID:seiyria,项目名称:deck.zone,代码行数:3,代码来源:create-toolbar.component.ts
示例15: exportTemplate
exportTemplate() {
let templateData = this.templateService.templateData;
let blob = new Blob([templateData], { type: 'text/json;charset=utf-8' });
saveAs(blob, 'template.json');
}
开发者ID:msshli,项目名称:arm-visualizer,代码行数:5,代码来源:menu-bar.component.ts
示例16: saveAsExcelFile
private saveAsExcelFile(buffer: any, fileName: string): void {
const data: Blob = new Blob([buffer], {
type: EXCEL_TYPE
});
FileSaver.saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION);
}
开发者ID:Zach-Mooneyhan,项目名称:excel-export,代码行数:6,代码来源:excel.service.ts
示例17: downloadFile
private downloadFile(data: string, title: string, mime: string): void {
FileSaver.saveAs(new File([data], title, {type: mime + ';charset=utf-8'}));
}
开发者ID:azavea,项目名称:climate-change-lab,代码行数:3,代码来源:data-export.service.ts
示例18:
.subscribe(res => {
FileSaver.saveAs(res, 'kubeconfig');
});
开发者ID:marynaKhromova,项目名称:console,代码行数:3,代码来源:organisation.component.ts
示例19: saveAs
.then(blob => saveAs(blob, `${deckName}.apkg`))
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:1,代码来源:downloadAndSaveDeck.ts
示例20: save
save() {
const blob = new Blob([angular.toJson(this.dash, true)], {
type: 'application/json;charset=utf-8',
});
saveAs(blob, this.dash.title + '-' + new Date().getTime() + '.json');
}
开发者ID:ArcticSnowman,项目名称:grafana,代码行数:6,代码来源:export_modal.ts
注:本文中的file-saver.saveAs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论