Académique Documents
Professionnel Documents
Culture Documents
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
using Excel = Microsoft.Office.Interop.Excel;
namespace WindowsFormsApplication5
{
public partial class lis : Form
{
Microsoft.Office.Interop.Excel.Application xlexcel;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
public lis()
{
InitializeComponent();
}
int z;
string bacadata;
xlexcel.Visible = true;
// Open a File
xlWorkBook = xlexcel.Workbooks.Open("D:\\cobasimpan.xlsx",
0, true, 5, "", "", true,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t",
false, false, 0, true, 1, 0);
xlWorkSheet =
(Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Cells[1, 1] = "Suhu";
xlWorkSheet.Cells[1, 2] = "Kelembaban";
xlWorkSheet.Cells[1, 3] = "Tekanan Udara";
xlWorkSheet.Cells[1, 4] = "UV";
}
else
MessageBox.Show("Anda Belum Terhubung Kemana - Mana");
}
else
{
MessageBox.Show("Anda Sudah Terhubung");
}
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("Port Sudah Terpakai");
}
}
xlWorkSheet.Cells[_lastRow, 1] = suhu.Text;
xlWorkSheet.Cells[_lastRow, 2] = kelembaban.Text;
xlWorkSheet.Cells[_lastRow, 3] = tek_udara.Text;
xlWorkSheet.Cells[_lastRow, 4] = UV.Text;
}
else
{
MessageBox.Show("Anda Belum Terhubung Kemana - Mana");
}
}
}
}