保存路径?保存excel到sql?
我真的很困惑如何去做这件事。
- 我希望能够使用以下命令从我的网络应用程序上传 Excel 工作表 文件上传控制。
- 接下来,我想读取第一行下的每一行。 (因此从第 2 行开始,第 1 行将是列标题)。
- 最后,我想将我读到的字符串传递到另一个方法中,该方法将用它执行我想要的操作,然后发布到网格视图。
我打算如何这样做...
由于我的网络应用程序发布在网络上,托管在我的本地盒子上...我上传的文件的常用保存路径(桌面)不起作用。
所以我想将它保存到 SQL Server 上,该 SQL Server 也托管在我的本地机器上。
因此,我想我正在尝试:
- 将上传的 Excel 保存到 SQL 数据库中。
- 读取 Excel 中的每一行并将其传递给预期的方法。
好吧,这太令人困惑了。必须有一种更简单的方法来做到这一点! (我真的需要 SQL 数据库吗?)
哦,对我的 savePath 有什么好的想法吗?
I'm really confused on how to go about doing this.
- I want to be able to upload an excel sheet from my web app using the
file upload control. - Next, I want to read each individual row under the first row. (So starting from row 2, row 1 will be the column title).
- Finally, I want to pass the Strings I've read into another method that'll do what I want with it and then post to a gridview.
How I intend to do so...
Since I have my web app published on the network, hosted on my local box... my usual savepath for the file uploaded (desktop) doesn't work.
So I thought to save it onto a SQL Server that is also hosted on my local box.
Therefore, I guess I'm trying to:
- Save the uploaded excel into a SQL database.
- Read each line from the excel and pass it through the intended method.
Okay, that was super confusing. There must be an easier way to do this! (Do I really need a SQL database?)
Oh, and any good ideas for my savePath?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还没有真正解决这个问题。但使用 OleDBConnection 读取 excel 文件上的内容会更容易,如下所示:
然后,传递到另一个方法,该方法使用 SqlConnection 写入 SQL Server。像这样:
Haven't really solved this. But it's easier to read whatever's on the excel file using the OleDBConnection like this:
Then, pass into another method, which uses SqlConnection to write into SQL Server. Like this: