扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
你就不能这样保存么? ↓
西宁网站建设公司成都创新互联公司,西宁网站设计制作,有大型网站制作公司丰富经验。已为西宁上千提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的西宁做网站的公司定做!
Static SaveNumber as Integer
SaveNumber += 1
Dim SavePath as String = "C:\ytakqi" SaveNumber ".png"
bit.Save(SavePath)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'定义Word对象
Dim wordApp As New Word.ApplicationClass
'要转换的文件名
Dim fileName As Object = "E:\Test.doc"
'默认值
Dim miss As Object = System.Reflection.Missing.Value
'打开要转换的 DOC 文件
Dim doc As Word.Document = DirectCast(wordApp.Documents.Open(fileName, miss, miss, miss, miss, miss, _
miss, miss, miss, miss, miss, miss, _
miss, miss, miss, miss), Word.Document)
'转换后的文件名
fileName = "E:\testDoc.HTML"
'保存的文件格式
Dim saveFormat As Object = Word.WdSaveFormat.wdFormatHTML
'按文本文件保存
doc.SaveAs(fileName, saveFormat, miss, miss, miss, miss, _
miss, miss, miss, miss, miss, miss, _
miss, miss, miss, miss)
'关闭是否保存文件,这里为不保存
Dim changes As Object = False
'关闭文件
doc.Close(changes, miss, miss)
'退出 Word 应用程序
wordApp.Quit(changes, miss, miss)
End Sub
private void Save_Click(object sender, System.EventArgs e) { // Create a new save file dialog SaveFileDialog saveFileDialog1 = new SaveFileDialog(); // Sets the current file name filter string, which determines // the choices that appear in the "Save as file type" or // "Files of type" box in the dialog box. saveFileDialog1.Filter = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|SVG (*.svg)|*.svg|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif"; saveFileDialog1.FilterIndex = 2 ; saveFileDialog1.RestoreDirectory = true ; // Set image file format if(saveFileDialog1.ShowDialog() == DialogResult.OK) { ChartImageFormat format = ChartImageFormat.Bmp; if( saveFileDialog1.FileName.EndsWith( "bmp" ) ) { format = ChartImageFormat.Bmp; } else if( saveFileDialog1.FileName.EndsWith( "jpg" ) ) { format = ChartImageFormat.Jpeg; } else if( saveFileDialog1.FileName.EndsWith( "emf" ) ) { format = ChartImageFormat.Emf; } else if( saveFileDialog1.FileName.EndsWith( "gif" ) ) { format = ChartImageFormat.Gif; } else if( saveFileDialog1.FileName.EndsWith( "png" ) ) { format = ChartImageFormat.Png; } else if( saveFileDialog1.FileName.EndsWith( "tif" ) ) { format = ChartImageFormat.Tiff; } else if( saveFileDialog1.FileName.EndsWith( "svg" ) ) { format = ChartImageFormat.Svg; } // Save image Chart1.SaveImage( saveFileDialog1.FileName, format ); } }
添加一个SaveFileDialog,在保存excle选择时候添加
SaveFileDialog1.show()
用法跟OpenFileDialog相同
可以用SaveFileDialog1对话框加上对文件数据操作的类来实现,,用richtextbox自己的属性方法也能行!我以前做过一个记事本程序就是那样的!
Public Class Cls导入数据
Dim xlApp As New Excel.Application()
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim A = "A"
Public Function 导出到Excel(ByVal Dt表 As DataTable) As Boolean
Dim rowIndex, colIndex As Integer
rowIndex = 1
colIndex = 0
xlBook = xlApp.Workbooks().Add
xlSheet = xlBook.Worksheets("sheet1")
Dim Table As New DataTable()
Table = CreaTable()
'将所得到的表的列名,赋值给单元格
Dim Col As DataColumn
Dim Row As DataRow
For Each Col In Table.Columns
colIndex = colIndex + 1
xlApp.Cells(1, colIndex) = Col.ColumnName
Next
'得到的表所有行,赋值给单元格
For Each Row In Table.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each Col In Table.Columns
colIndex = colIndex + 1
xlApp.Cells(rowIndex, colIndex) = Row(Col.ColumnName)
Next
Next
With xlSheet
.Range(.Cells(1, 1), .Cells(1, colIndex)).Font.Name = "黑体"
'设标题为黑体字
.Range(.Cells(1, 1), .Cells(1, colIndex)).Font.Bold = True
'标题字体加粗
.Range(.Cells(1, 1), .Cells(rowIndex, colIndex)).Borders.LineStyle = 1
'设表格边框样式
End With
With xlSheet.PageSetup
.LeftHeader = "" Chr(10) """楷体_GB2312,常规""10公司名称:" ' Gsmc
.CenterHeader = """楷体_GB2312,常规""公司人员情况表""宋体,常规""" Chr(10) """楷体_GB2312,常规""10日 期:"
.RightHeader = "" Chr(10) """楷体_GB2312,常规""10单位:"
.LeftFooter = """楷体_GB2312,常规""10制表人:"
.CenterFooter = """楷体_GB2312,常规""10制表日期:"
.RightFooter = """楷体_GB2312,常规""10第P页 共N页"
End With
xlApp.SaveWorkspace()
MsgBox("保存完毕", MsgBoxStyle.Exclamation, "提示")
KillAllExcels()
'xlApp.Visible = True
End Function
Sub KillAllExcels()
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
proc.Kill()
Next
End Sub
end class
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流