在尝试使用 ClosedXML 构建 Excel 文件时,我遇到了一些有关内存流的意外行为。在调试器中,我可以看到 MemoryStream ms 正在由该wb.SaveAs()函数填充。但是,当直接将其传递到 时DotNetStreamReference,该文件将作为 0 字节的 blob 下载。
奇怪的是,当我将流转换为字节数组并返回流时,该函数按预期工作。
我在这里错过了一些基本的东西吗?
这是使用MS 示例得出的
技术:
C# 代码
async Task ExportToExcel()
{
string fileName = $"DocumentsExport{DateTime.UtcNow.Ticks}.xlsx";
var wb = new ClosedXML.Excel.XLWorkbook();
var ws = wb.AddWorksheet("Documents");
// construct headers
ws.Cell(1, 1).SetValue<string>("Document Name");
ws.Cell(1, 2).SetValue<string>("Description");
ws.Cell(1, 3).SetValue<string>("Sort Order");
ws.Cell(1, 4).SetValue<string>("Category Name");
ws.Cell(1, 5).SetValue<string>("Group Name");
ws.Cell(1, 6).SetValue<string>("Date Modified");
// construct worksheet contents
for (int i = 0; i < documents.Count; …Run Code Online (Sandbox Code Playgroud) 我将如何向使用嵌套对象的 MudBlazor DataGrid 添加列?
例如,我有一个名为 Foo 的基本实体,它具有以下组成:
public class Foo
{
public int Id {get; set;}
public Bar Bar {get; set;}
}
public class Bar
{
public string Name {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
如何将 Bar.Name 添加到MudBlazor 的 DataGrid中的列?
<MudDataGrid Items="@someIEnumerableOfTypeFoo">
<Columns>
<Column T="Foo" Field="Id" Title="Id" />
<Column T="Foo" Field="Bar.Name" /> <!-- This Fails -->
</Columns>
</MudDataGrid>
Run Code Online (Sandbox Code Playgroud) 看起来很简单,但我似乎找不到正确的语法。我希望在 Access 2013 应用程序中为未打开的表单创建一个表单变量,以便我可以将表单对象传递给一系列方法,而不是传递表单的单独属性。
这是我一直在尝试的,但遇到运行时错误“2465”“Microsoft Access 找不到表达式中引用的字段“frmSuppliers”。
Private Sub cmdSuppliers_Click()
Dim frm As Form
Set frm = Form("frmSuppliers")
Debug.Print frm.Name
Run Code Online (Sandbox Code Playgroud)