如何在C#中创建excel

编程入门 行业动态 更新时间:2024-10-27 06:19:38
本文介绍了如何在C#中创建excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想创建excel文件,将内存流中的数据添加到excel。 我尝试过: 我使用了以下代码。

I want to create the excel file add the data from memory stream from to excel. What I have tried: I used the follwing code.

File.Create(filepath).Close(); var memory = new MemoryStream() byte[] bytes = File.ReadAllBytes(Path.Combine(fullPath, fileName)); memory.Write(bytes, 0, bytes.Length);

它正在创建excel文件,但是当我尝试打开,它给了消息我们发现'文件'中的一些内容有问题。你想我们尽可能多地恢复吗?如果你信任这个工作簿的来源,请点击是

it is creating the excel file but when i am trying to open, it is giving messanger "We found problem with some contents in 'filename'. Do you want to us try to recover as much as we can? If you trust the source of this workbook click Yes"

推荐答案

您只创建文件而不是Excel文档。有完整的过程需要遵循,首先添加excel插件然后创建连接 看到这个博客 - 如何在C#中创建Excel文件 [ ^ ] You are creating only file not excel documents. there is whole process which you need to follow , start by adding excel addins and then creating connection see this blog- How to create Excel file in C#[^]

本文如何使用C#创建Excel文件 [ ^ ]可能会帮助您学习如何创建excel文件。 This article How to Create Excel File Using C#[^] might help you to learn how to create excel file.

您可以点击下面的链接, 如何在C#中创建Excel文件 [ ^ ] 希望它可以帮到你。 hi follow the link bellow, How to create Excel file in C#[^] Hope it helps you.

更多推荐

如何在C#中创建excel

本文发布于:2023-11-03 06:55:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554498.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!