c#保存数据到Excel表-简单方式
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ODSensor
{
public class SaveData
{
FileStream outFileStream = null;
StreamWriter saveWriter = null;
int MAX_FILE_LENGTH = 1000000;
int COUNTER_FILE_LENGTH = 0;
String saveFileName = "\\测量记录";
String fileName;
String currentDIR = "";
String speFileName;
char temp = ' ';
private float interTime = 1;
int dirNum = 0;
private bool isOpenFile = false;
private bool change_dir = true;
public SaveData()
{
}
/// <summary>
/// 设置intertime的值
/// </summary>
public void setinterTime(float inter)
{
interTime = inter;
}
public void initSaveFile(String dir, String extDir, String extDir2, String tmpFileName, bool isLimit)
{
change_dir = isLimit;
speFileName = tmpFileName;
COUNTER_FILE_LENGTH = 0;
if (dir != "")
{
if (extDir.Equals(""))
{
currentDIR = dir;
}
else if (extDir2.Equals(""))
{
currentDIR = dir + "\\" + extDir + "\\";
}
else
{
currentDIR = dir + "\\" + extDir + "\\" + extDir2 + "\\";
}
//currentDIR = dir + "\\" + extDir;
}
else
{
//currentDIR = Directory.GetCurrentDirectory()+saveFileName;
if (extDir.Equals(""))