【TeeChart Pro ActiveX教程】(十二):導入和導出圖表(上)
本教程概述了以各種格式導出TeeCharts并導入TeeChart自己的.ten格式圖表模板。
導出圖表
可用格式
可用導出格式??梢詫⑺懈袷綇椭频轿募蚣糍N板或Stream。
圖像格式
- BMP:BitmapFormat類
- JPEG:JPEGFormat類
- WMF和EMF:MetafileFormat類
- GIF:GIFFormat類
- PNG:PNGFormat類
- TIFF:TIFFFormat類
數(shù)據(jù)格式
- Text:TextFormat類
- XML:XMLFormat類
- HTML:HTMLFormat類
- Excel:ExcelFormat類
其他格式
ten格式是一種靈活的格式,可存儲圖表屬性信息和(可選)圖表數(shù)據(jù)。文件很?。ㄈQ于數(shù)據(jù)),非常適合網(wǎng)絡(luò)用于更新基于實時客戶端的圖表。
- TEN(TeeChart):TemplateExport類
示例導出
導出到文件是合理的,在大多數(shù)情況下,您只需要定義目標文件名。
[C#]
private void button1_Click(object sender, System.EventArgs e) saveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|Images(*.emf)|*.emf|Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff"; saveFileDialog1.ShowDialog(); if(saveFileDialog1.FileName != "") switch(saveFileDialog1.FilterIndex) case 1: tChart1.Export.Image.Bitmap.Save(saveFileDialog1.FileName); break; case 2: tChart1.Export.Image.JPEG.Save(saveFileDialog1.FileName); break; case 3: tChart1.Export.Image.Metafile.Enhanced = false; tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName); break; case 4: tChart1.Export.Image.Metafile.Enhanced = true; tChart1.Export.Image.Metafile.Save(saveFileDialog1.FileName); break; case 5: tChart1.Export.Image.GIF.Save(saveFileDialog1.FileName); break; case 6: tChart1.Export.Image.PNG.Save(saveFileDialog1.FileName); break; case 7: tChart1.Export.Image.TIFF.Save(saveFileDialog1.FileName); break;
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SaveFileDialog1.Filter = "Images (*.bmp)|*.bmp|Images(*.jpg)|*.jpg|Images(*.wmf)|*.wmf|Images(*.emf)|*.emf|Images (*.gif)|*.gif|Images (*.png)|*.png|Images (*.tiff)|*.tiff" SaveFileDialog1.ShowDialog() If SaveFileDialog1.FileName <> "" Then Select Case SaveFileDialog1.FilterIndex Case 1 TChart1.Export.Image.Bitmap.Save(SaveFileDialog1.FileName) Case 2 TChart1.Export.Image.JPEG.Save(SaveFileDialog1.FileName) Case 3 TChart1.Export.Image.Metafile.Enhanced = False TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName) Case 4 TChart1.Export.Image.Metafile.Enhanced = True TChart1.Export.Image.Metafile.Save(SaveFileDialog1.FileName) Case 5 TChart1.Export.Image.GIF.Save(SaveFileDialog1.FileName) Case 6 TChart1.Export.Image.PNG.Save(SaveFileDialog1.FileName) Case 7 TChart1.Export.Image.TIFF.Save(SaveFileDialog1.FileName) End Select End If End Sub
導出圖片
BMP
BMP文件導出具有顏色和大小的附加參數(shù),例
[C#]
case 1: Steema.TeeChart.Export.BitmapFormat bitMap = tChart1.Export.Image.Bitmap; bitMap.Height = 500; bitMap.Width = 700; bitMap.Monochrome = true; bitMap.Save(saveFileDialog1.FileName); break;
[VB.Net]
Case 1 Dim BitMap As Steema.TeeChart.Export.BitmapFormat = TChart1.Export.Image.Bitmap BitMap.Height = 500 BitMap.Width = 700 BitMap.Monochrome = True BitMap.Save(SaveFileDialog1.FileName)
JPEG
JPEG文件導出現(xiàn)在具有SaveToFile和SaveToStream的速度和質(zhì)量參數(shù),例
[C#]
case 2: Steema.TeeChart.Export.JPEGFormat jPEG = tChart1.Export.Image.JPEG; jPEG.GrayScale = true; jPEG.Height = 500; jPEG.Width = 700; jPEG.Quality = 100; jPEG.Save(saveFileDialog1.FileName); break;
[VB.Net]
Case 2 Dim JPEGf As Steema.TeeChart.Export.JPEGFormat = TChart1.Export.Image.JPEG JPEGf.Height = 500 JPEGf.Width = 700 JPEGf.GrayScale = True JPEGf.Quality = 100 JPEGf.Save(SaveFileDialog1.FileName)
質(zhì)量值(從1到100)將使文件更大,從而更慢地通過網(wǎng)絡(luò)傳輸 - 但質(zhì)量更好!您需要根據(jù)自己的應(yīng)用決定最佳平衡。通過將“Enhanced”設(shè)置為True,可以簡單地創(chuàng)建
WMF和EMF
增強型圖元文件,例
[C#]
case 3: Steema.TeeChart.Export.MetafileFormat metaFile = tChart1.Export.Image.Metafile; metaFile.Height = 500; metaFile.Width = 700; metaFile.Enhanced = false; metaFile.Save(saveFileDialog1.FileName); break;
[VB.Net]
Case 3 Dim MetaFile As Steema.TeeChart.Export.MetafileFormat = TChart1.Export.Image.Metafile MetaFile.Height = 500 MetaFile.Width = 700 MetaFile.Enhanced = False MetaFile.Save(SaveFileDialog1.FileName)
由于Microsoft的.Net Framework類庫,特別是 System.Drawing.Imaging命名空間中包含的類, GIF TeeChart for .Net能夠支持以GIF格式導出位圖,例
[C#]
case 5: Steema.TeeChart.Export.GIFFormat gIF = tChart1.Export.Image.GIF; gIF.Height = 500; gIF.Width = 700; gIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale; gIF.Save(saveFileDialog1.FileName); break;
[VB.Net]
Case 5 Dim GIF As Steema.TeeChart.Export.GIFFormat = TChart1.Export.Image.GIF GIF.Height = 500 GIF.Width = 700 GIF.ColorReduction = Steema.TeeChart.Export.GIFFormat.GIFColorReduction.GrayScale GIF.Save(SaveFileDialog1.FileName)
PNG
PNG格式保留了GIF格式的許多優(yōu)點,但也提供了超出GIF格式的功能。PNG改進了GIF逐步顯示圖像的能力; 也就是說,當圖像通過網(wǎng)絡(luò)連接到達時,顯示更好和更好的圖像近似值,例:
[C#]
case 6: Steema.TeeChart.Export.PNGFormat pNG = tChart1.Export.Image.PNG; pNG.Compression = 100; pNG.GrayScale = true; pNG.Height = 500; pNG.Width = 700; pNG.Save(saveFileDialog1.FileName); break;
[VB.Net]
Case 6 Dim PNGf As Steema.TeeChart.Export.PNGFormat = TChart1.Export.Image.PNG PNGf.Compression = 100 PNGf.GrayScale = True PNGf.Height = 500 PNGf.Width = 700 PNGf.Save(SaveFileDialog1.FileName)
TIFF
TIFF是一種靈活且可擴展的格式,受到各種平臺和圖像處理應(yīng)用程序的支持。 例
[C#]
case 7: Steema.TeeChart.Export.TIFFFormat tIFF = tChart1.Export.Image.TIFF; tIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW; tIFF.Height = 500; tIFF.Width = 700; tIFF.Save(saveFileDialog1.FileName); break;
[VB.Net]
Case 7 Dim TIFF As Steema.TeeChart.Export.TIFFFormat = TChart1.Export.Image.TIFF TIFF.Compression = Steema.TeeChart.Export.TIFFFormat.TIFFCompression.LZW TIFF.Height = 500 TIFF.Width = 700 TIFF.Save(SaveFileDialog1.FileName)
Adobe Flex/Flash/SWF
TeeChart現(xiàn)在可以導出到Adobe Flex腳本文件(* .mxml),然后可以通過Flex的免費編譯器(mxmlc.exe)進行編譯,以創(chuàng)建* .swf(Flash)文件。有關(guān)如何在運行時實現(xiàn)此功能的詳細示例,包括如何向?qū)С龅膱D表添加動畫的詳細信息。
購買TeeChart Pro AciveX正版授權(quán),請點擊“咨詢在線客服”喲!