Initial commit

This commit is contained in:
2026-06-02 10:51:14 +02:00
committed by kawa
commit d19092c84e
182 changed files with 13757 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
using System.Text;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace SharepointToolbox.Web.Services.Export;
/// <summary>
/// Triggers browser file downloads from Blazor Server components.
/// Converts string export outputs to bytes and invokes JS download.
/// </summary>
public class WebExportService
{
private readonly IJSRuntime _js;
public WebExportService(IJSRuntime js) { _js = js; }
public async Task DownloadCsvAsync(string content, string fileName)
{
var bytes = new UTF8Encoding(encoderShouldEmitUTF8Identifier: true).GetBytes(content);
await _js.InvokeVoidAsync("sptb.downloadFile", fileName, "text/csv;charset=utf-8", Convert.ToBase64String(bytes));
}
public async Task DownloadHtmlAsync(string content, string fileName)
{
var bytes = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false).GetBytes(content);
await _js.InvokeVoidAsync("sptb.downloadFile", fileName, "text/html;charset=utf-8", Convert.ToBase64String(bytes));
}
}