|
@@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|
|
using Extensometer.Data;
|
|
|
using Extensometer.Model;
|
|
|
using Extensometer.Model.ResultModel;
|
|
|
-using Microsoft.Office.Interop.Excel;
|
|
|
|
|
|
namespace Extensometer.BLL
|
|
|
{
|
|
@@ -92,45 +91,45 @@ namespace Extensometer.BLL
|
|
|
/// <param name="list"></param>
|
|
|
/// <param name="FilePath"></param>
|
|
|
/// <returns></returns>
|
|
|
- public ResultModel DataExport(List<ObjectData> list,string FilePath)
|
|
|
- {
|
|
|
- ResultModel resultModel = new ResultModel();
|
|
|
- if (list.Count > 0)
|
|
|
- {
|
|
|
- object misValue = Missing.Value;
|
|
|
- Application xlApp = new Application();
|
|
|
- Workbook xlWorkBook = xlApp.Workbooks.Add(misValue);
|
|
|
- Worksheet xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);
|
|
|
+ //public ResultModel DataExport(List<ObjectData> list,string FilePath)
|
|
|
+ //{
|
|
|
+ // ResultModel resultModel = new ResultModel();
|
|
|
+ // if (list.Count > 0)
|
|
|
+ // {
|
|
|
+ // object misValue = Missing.Value;
|
|
|
+ // Application xlApp = new Application();
|
|
|
+ // Workbook xlWorkBook = xlApp.Workbooks.Add(misValue);
|
|
|
+ // Worksheet xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);
|
|
|
|
|
|
- PropertyInfo[] props = GetPropertyInfoArray();
|
|
|
- for (int i = 0; i < props.Length; i++)
|
|
|
- {
|
|
|
- xlWorkSheet.Cells[1, i + 1] = props[i].Name; //write the column name
|
|
|
- }
|
|
|
- for (int i = 0; i < list.Count; i++)
|
|
|
- {
|
|
|
- xlWorkSheet.Cells[i + 2, 1] = list[i].GaugeLeng.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 2] = list[i].Time.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 3] = list[i].Point1x.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 4] = list[i].Point1y.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 5] = list[i].Point2x.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 6] = list[i].Point2y.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 7] = list[i].StrainValue.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 8] = list[i].Distance.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 9] = list[i].Displacement.ToString();
|
|
|
- xlWorkSheet.Cells[i + 2, 10] = list[i].ForceValue.ToString();
|
|
|
- }
|
|
|
- try
|
|
|
- {
|
|
|
- xlWorkBook.SaveAs(FilePath, XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
|
|
|
- xlWorkBook.Close(true, misValue, misValue);
|
|
|
- xlApp.Quit();
|
|
|
- }
|
|
|
- catch
|
|
|
- { }
|
|
|
- }
|
|
|
- return resultModel;
|
|
|
- }
|
|
|
+ // PropertyInfo[] props = GetPropertyInfoArray();
|
|
|
+ // for (int i = 0; i < props.Length; i++)
|
|
|
+ // {
|
|
|
+ // xlWorkSheet.Cells[1, i + 1] = props[i].Name; //write the column name
|
|
|
+ // }
|
|
|
+ // for (int i = 0; i < list.Count; i++)
|
|
|
+ // {
|
|
|
+ // xlWorkSheet.Cells[i + 2, 1] = list[i].GaugeLeng.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 2] = list[i].Time.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 3] = list[i].Point1x.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 4] = list[i].Point1y.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 5] = list[i].Point2x.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 6] = list[i].Point2y.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 7] = list[i].StrainValue.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 8] = list[i].Distance.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 9] = list[i].Displacement.ToString();
|
|
|
+ // xlWorkSheet.Cells[i + 2, 10] = list[i].ForceValue.ToString();
|
|
|
+ // }
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+ // xlWorkBook.SaveAs(FilePath, XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
|
|
|
+ // xlWorkBook.Close(true, misValue, misValue);
|
|
|
+ // xlApp.Quit();
|
|
|
+ // }
|
|
|
+ // catch
|
|
|
+ // { }
|
|
|
+ // }
|
|
|
+ // return resultModel;
|
|
|
+ //}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询数据库路径是否为空
|