using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace DataStatistic.Common
{
private XmlDocument _doc;
public XmlClass()
{
if (System.IO.File.Exists("data.xml"))
{
_doc = new XmlDocument();
_doc.Load("data.xml");
}
}
public List<GenerateExcelThreadData> getdata()
{
List<GenerateExcelThreadData> data = new List<GenerateExcelThreadData>();
if (null != _doc)
{
foreach (XmlNode node in _doc.SelectNodes("/content/data"))
{
string excelfilepath = string.Empty, excelfilename = string.Empty, sheetname = string.Empty, sql = string.Empty, fullExcelFilePath = string.Empty;
foreach (XmlNode datanode in node.ChildNodes)
{
if (datanode.Name.Equals("excelfilepath"))
{
excelfilepath = datanode.InnerText.Trim();
}
else if (datanode.Name.Equals("excelfilename"))
{
excelfilename = datanode.InnerText.Trim();
}
else if (datanode.Name.Equals("sheetname"))
{
sheetname = datanode.InnerText.Trim();
}
else if (datanode.Name.Equals("sql"))
{
sql = datanode.InnerText.Trim();
}
}
if ((!string.IsNullOrEmpty(excelfilepath)) && (!string.IsNullOrEmpty(excelfilename)))
{
fullExcelFilePath = excelfilepath + (excelfilepath.EndsWith("\\") ? "" : "\\") + Common.gettodaydate()+"-" + excelfilename;
}
GenerateExcelThreadData td = new GenerateExcelThreadData(fullExcelFilePath, sheetname, sql);
data.Add(td);
}
}
return data;
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace DataStatistic.Common
{
class GenerateExcelThreadData
{
public string excelFilePath;
public string sheetName;
public string sql;
public GenerateExcelThreadData(string excelFilePath , string sheetName ,string sql)
{
this.sql = sql;
this.excelFilePath = excelFilePath;
this.sheetName = sheetName;
if (string.IsNullOrEmpty(this.sheetName))
{
this.sheetName = "sheetGenerate";
}
}
{
private XmlDocument _doc;
public XmlClass()
{
if (System.IO.File.Exists("data.xml"))
{
_doc = new XmlDocument();
_doc.Load("data.xml");
}
}
public List<GenerateExcelThreadData> getdata()
{
List<GenerateExcelThreadData> data = new List<GenerateExcelThreadData>();
if (null != _doc)
{
foreach (XmlNode node in _doc.SelectNodes("/content/data"))
{
string excelfilepath = string.Empty, excelfilename = string.Empty, sheetname = string.Empty, sql = string.Empty, fullExcelFilePath = string.Empty;
foreach (XmlNode datanode in node.ChildNodes)
{
if (datanode.Name.Equals("excelfilepath"))
{
excelfilepath = datanode.InnerText.Trim();
}
else if (datanode.Name.Equals("excelfilename"))
{
excelfilename = datanode.InnerText.Trim();
}
else if (datanode.Name.Equals("sheetname"))
{
sheetname = datanode.InnerText.Trim();
}
else if (datanode.Name.Equals("sql"))
{
sql = datanode.InnerText.Trim();
}
}
if ((!string.IsNullOrEmpty(excelfilepath)) && (!string.IsNullOrEmpty(excelfilename)))
{
fullExcelFilePath = excelfilepath + (excelfilepath.EndsWith("\\") ? "" : "\\") + Common.gettodaydate()+"-" + excelfilename;
}
GenerateExcelThreadData td = new GenerateExcelThreadData(fullExcelFilePath, sheetname, sql);
data.Add(td);
}
}
return data;
}
}
}