【问题标题】:How will I export the data from listview to excel and pdf in VB.NET如何在 VB.NET 中将数据从 listview 导出到 excel 和 pdf
【发布时间】:2016-10-14 13:52:19
【问题描述】:

大家好!

我可以请求您的帮助吗? :) 我的问题是如何在不使用数据库或水晶报表的情况下直接将数据从 listview 导出到 excel 和 PDF。有没有可能的方法可以做到这一点?

谢谢! :)

请查看以下链接中的图片

http://postimg.org/image/fjcgk0oap/6226dbd8/


您好先生 - 我包括我的数据源和用于搜索数据的代码。请帮助我。谢谢!

Dim con As New MySqlConnection("Server = localhost; database=complain; uid=root;pwd=admin1950")
con.Open() 
Dim query = "SELECT * FROM tbl_complain WHERE status=@status order by store, date_complaint DESC, time_complaint DESC" 
Dim cmd = New MySqlCommand(query, con) 
cmd.Parameters.AddWithValue("@status", combo_status.Text)

【问题讨论】:

  • 现在,问题出在哪里?您在从数据库中检索文本时遇到问题吗?您可以检索它但不能将其插入到excel中吗?可以在excel中插入但不能导出为pdf吗?

标签: vb.net excel listview pdf


【解决方案1】:

在不知道您的数据源(例如,数据库连接...)的情况下,一旦数据在 excel 中可用,并且您想将该范围保存为 pdf,您可以试试这个。

Sheets("sheetname").Range("yourrange...b1:327...").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "c:\Book1.pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True

【讨论】:

  • 您好先生 - 我包括我的数据源和搜索数据的代码。请帮助我。谢谢! Dim con As New MySqlConnection("Server = localhost; database=complain; uid=root;pwd=admin1950") con.Open() Dim query = "SELECT * FROM tbl_complain WHERE status=@status order by store, date_complaint DESC, time_complaint DESC" Dim cmd = New MySqlCommand(query, con) cmd.Parameters.AddWithValue("@status", combo_status.Text)
  • @RonnMatthewMoreno 请用你的代码编辑你的问题,而不是把它放在评论中,这变得不可读......
  • @DrDonut 嗨,先生-请再次阅读我的问题。谢谢你们! :)
  • 您是说暂时无法将数据输入到 Excel 工作表中吗?
  • 抱歉回复晚了。 @chungtinhlakho 是的。我在 listview 中有数据,我想将其导出到 excel 中。我将如何做到这一点?谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-12-12
  • 2018-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多