資源簡介
c#中串口接收數據并且生成EXCEL

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO.Ports;
using?Aspose.Cells;
namespace?WindowsFormsApplication1
{
????public?partial?class?Form1?:?Form
????{
????????const?byte?DeviceOpen1?=?0xb2;
????????const?byte?DeviceOpen2?=?0xb0;
????????int?n?=?0flag_js=0;
????????public?Form1()
????????{
????????????InitializeComponent();
????????????serialPort1.DataReceived?+=?new?SerialDataReceivedEventHandler(port_DataReceived);??????//串口數據接收事件
????????????serialPort1.Encoding?=?Encoding.GetEncoding(“GB2312“);??????????????????????????????????//串口接收編碼
????????????System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls?=?false;
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????this.listView1.BeginUpdate();???//數據更新,UI暫時掛起,直到EndUpdate繪制控件,可以有效避免閃爍并大大提高加載速度
????????????listView1.View?=?View.Details;
????????????listView1.GridLines?=?true;
????????????listView1.Columns.Clear();
????????????listView1.Columns.Add(“NUM“?50?HorizontalAlignment.Center);
????????????listView1.Columns.Add(“Data?and?time“?200?HorizontalAlignment.Center);
????????????listView1.Columns.Add(“Sample?ID“?70?HorizontalAlignment.Center);
????????????listView1.Columns.Add(“Measured?Value“?150?HorizontalAlignment.Center);
????????????listView1.Columns.Add(“Temperature“?100?HorizontalAlignment.Center);
????????????ImageList?iList?=?new?ImageList();
????????????iList.ImageSize?=?new?Size(1?15);//寬度和高度值必須大于等于1且不超過256
????????????this.listView1.SmallImageList?=?iList;//這樣的結果在第一列的前面多出了1個分量的寬,所有行的高度為24
????????????listView1.Refresh();
????????????this.listView1.EndUpdate();??//結束數據處理,UI界面一次性繪制。
????????}
????????private?void?SearchAndAddSerialToComboBox(SerialPort?MyPort?ComboBox?MyBox)
????????{???????????????????????????????????????????????????????????????//將可用端口號添加到ComboBox
????????????//string[]?MyString?=?new?string[20];?????????????????????????//最多容納20個,太多會影響調試效率
????????????string?Buffer;??????????????????????????????????????????????//緩存
????????????MyBox.Items.Clear();????????????????????????????????????????//清空ComboBox內容
????????????for?(int?i?=?1;?i?20;?i++)????????????????????????????????//循環
????????????{
????????????????try?????????????????????????????????????????????????????//核心原理是依靠try和catch完成遍歷
????????????????{
????????????????????Buffer?=?“COM“?+?i.ToString();
????????????????????MyPort.PortName?=?Buffer;
????????????????????MyPort.Open();??????????????????????????????????????//如果失敗,后面的代碼不會執行
????????????????????MyBox.Items.Add(Buffer);????????????????????????????//打開成功,添加至下倆列表
????????????????????MyBox.Text?=?Buffer;
????????????????????MyPort.Close();?????????????????????????????????????//關閉
??
????????????????}
????????????????catch
????????????????{
????????????????????
????????????????}
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????7398912??2017-05-19?08:52??c#中串口接收數據并且生成EXCEL\com\com\bin\Debug\Aspose.Cells.dll
?????文件??????17408??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\bin\Debug\com.exe
?????文件??????32256??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\bin\Debug\com.pdb
?????文件??????11600??2017-05-26?09:38??c#中串口接收數據并且生成EXCEL\com\com\bin\Debug\com.vshost.exe
?????文件????????490??2010-03-17?22:39??c#中串口接收數據并且生成EXCEL\com\com\bin\Debug\com.vshost.exe.manifest
?????文件??????11600??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\bin\Debug\WindowsFormsApplication1.vshost.exe
?????文件????????490??2010-03-17?22:39??c#中串口接收數據并且生成EXCEL\com\com\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
?????文件???????3942??2017-05-19?10:50??c#中串口接收數據并且生成EXCEL\com\com\com.csproj
?????文件????????227??2017-05-25?15:52??c#中串口接收數據并且生成EXCEL\com\com\com.csproj.user
?????文件??????17674??2017-05-26?09:30??c#中串口接收數據并且生成EXCEL\com\com\Form1.cs
?????文件???????6312??2017-05-26?09:30??c#中串口接收數據并且生成EXCEL\com\com\Form1.Designer.cs
?????文件???????6016??2017-05-26?09:30??c#中串口接收數據并且生成EXCEL\com\com\Form1.resx
?????文件???????1466??2017-05-26?09:38??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\com.csproj.FileListAbsolute.txt
?????文件??????17408??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\com.exe
?????文件??????32256??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\com.pdb
?????文件???????4440??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6273??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????446??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\GenerateResource.read.1.tlog
?????文件???????1226??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\GenerateResource.write.1.tlog
?????文件??????19551??2017-05-25?15:39??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\ResolveAssemblyReference.cache
?????文件????????180??2017-05-26?09:31??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\WindowsFormsApplication1.Form1.resources
?????文件????????180??2017-05-25?15:52??c#中串口接收數據并且生成EXCEL\com\com\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources
?????文件????????516??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\Program.cs
?????文件???????1460??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\Properties\AssemblyInfo.cs
?????文件???????2874??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\Properties\Resources.Designer.cs
?????文件???????5612??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\Properties\Resources.resx
?????文件???????1107??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\Properties\Settings.Designer.cs
?????文件????????249??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com\Properties\Settings.settings
?????文件????????851??2017-05-17?16:12??c#中串口接收數據并且生成EXCEL\com\com.sln
????..A..H.?????21504??2017-05-26?09:37??c#中串口接收數據并且生成EXCEL\com\com.suo
............此處省略15個文件信息
- 上一篇:reflector中文版
- 下一篇:asp.net網上報名系統
評論
共有 條評論