小编ser*_*kov的帖子

如何向 StackBlitz Angular 项目添加组件?

我在 StackBlitz 上创建了基本的 Angular 项目,并想添加我的组件。我右键单击 src 文件夹,Angular Generator > Component > test,它创建了带有测试组件的文件夹“test”。但是,当我尝试将此组件添加到 my-app 组件模板时,出现错误:

Error in src/main.ts (15:5)
'app-test' is not a known element:
1. If 'app-test' is an Angular component, then verify that it is included in the '@Component.imports' of this component.
2. If 'app-test' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message.
Run Code Online (Sandbox Code Playgroud)

验证它是否包含在进口中

如果我进一步添加导入,则会收到另一个错误:

Error in src/main.ts (10:27)
The component 'TestComponent' appears in 'imports', but is not standalone and cannot …
Run Code Online (Sandbox Code Playgroud)

angular stackblitz

2
推荐指数
1
解决办法
1936
查看次数

如何将 OpenXML 从模板创建的 Word 文档转换为 MemoryStream?

我需要在 ASP.NET 控制器方法中将文档作为 MemoryStream 返回以在网页上下载它。我不想把这个文档保存在文件上,然后把它读成 MemoryStream 并返回。注意:重载方法 WordprocessingDocument.CreateFromTemplate(template) 没有流选项 vs WordprocessingDocument.Create(stream, ...)

保存临时文件的解决方案如下。

    public static MemoryStream GetWordDocumentFromTemplate()
    {
        string tempFileName = Path.GetTempFileName();
        var templatePath = AppDomain.CurrentDomain.BaseDirectory + @"Controllers\" + templateFileName;

        using (var document = WordprocessingDocument.CreateFromTemplate(templatePath))
        {
            var body = document.MainDocumentPart.Document.Body;

            //add some text 
            Paragraph paraHeader = body.AppendChild(new Paragraph());
            Run run = paraHeader.AppendChild(new Run());
            run.AppendChild(new Text("This is body text"));

            OpenXmlPackage savedDoc = document.SaveAs(tempFileName); // Save result document, not modifying the template
            savedDoc.Close();  // can't read if it's open
            document.Close();
        }

        var …
Run Code Online (Sandbox Code Playgroud)

c# memorystream ms-word openxml

1
推荐指数
1
解决办法
1492
查看次数

标签 统计

angular ×1

c# ×1

memorystream ×1

ms-word ×1

openxml ×1

stackblitz ×1