日期:2014-05-18  浏览次数:20761 次

求帮忙看看程序问题
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;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
using Excel = Microsoft.Office.Interop.Excel;


namespace WindowsFormsApplication19
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }

  private void button1_Click(object sender, EventArgs e)
  {
  int j = 0;
  double b1 = 0, b2 = 0;
  int d = 0;
  DateTime myDTTime = DateTime.Now;
  string myStrYear, myStrMonth, myStrDay, myStrDay1;
  string myStrFileName = "";
  myStrYear = myDTTime.Year.ToString().Substring(2, 2);
  if (myDTTime.Month > 9)
  {
  myStrMonth = myDTTime.Month.ToString();
  }
  else
  {
  myStrMonth = "0" + myDTTime.Month.ToString();
  }
  if (myDTTime.Day > 9)
  {
  myStrDay = myDTTime.Day.ToString();
  }
  else
  {
  myStrDay = "0" + myDTTime.Day.ToString();
  }
  d = Convert.ToInt32(myStrDay) - 1;
  myStrDay1 = Convert.ToString(d);

  myStrFileName = myStrYear + myStrMonth + myStrDay1 + "20.000";
   
  string a = myStrFileName;
  StreamReader myReader = new StreamReader(@"H:\high\temper\850\" + a, Encoding.GetEncoding("GB2312"));

  string myline = " ";
  myline = myReader.ReadLine();
  Microsoft.Office.Interop.Excel.Application excel1 = new Microsoft.Office.Interop.Excel.Application();
  Workbook workbook1 = excel1.Workbooks.Add(true);
  Worksheet worksheet1 = (Worksheet)workbook1.Worksheets["sheet1"];
   
  excel1.Visible = true;

   

   

  while ((myline = myReader.ReadLine()) != null)
  {

  j = j + 1;
  myline.Replace(" ", " ");
  myline.Replace(" ", " ");
  myline.Replace(" ", " ");
  string[] sArray = myline.Split(' ');


  if (j == 97)
  {
  b1 = Convert.ToDouble(sArray[8]);
  worksheet1.Cells[1, 1] = "温度";
  worksheet1.Cells[1, 2] = "b1";  

  }
  if (j == 103)
  {
  b2 = Convert.ToDouble(sArray[8]);
   
  }
   
  }

  double bb = b1 * 0.3 + b2 * 0.7、
  MessageBox.Show(bb + "\r\n");
  worksheet1.Cells[2, 1] = "温度";
  wor