|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using BPASmartClient.DosingSystem.ViewModel;
- using Microsoft.Office.Interop.Excel;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.DosingSystem.Model.ExcelModel
- {
- public class ExcelOperate
- {
- private volatile static ExcelOperate _Instance;
- public static ExcelOperate GetInstance => _Instance ?? (_Instance = new ExcelOperate());
- private ExcelOperate() { }
-
- /*public bool ExcelWrite(ObservableCollection<Allweight> allweights)
- {
-
- object misValue = System.Reflection.Missing.Value;
- Application app = new Application();
- Workbook wb = app.Workbooks.Add();
- Worksheet worksheet = (Worksheet)wb.Worksheets.get_Item(1);
- for (int i = 0; i < allweights.Count; i++)
- {
- worksheet.Cells[i+1,1] = allweights[i].RecipeName;
- }
- string filePath = @"C:\Users\刘耀文\Desktop\测试.xls";
- wb.SaveAs(filePath,XlFileFormat.xlWorkbookNormal,misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
- wb.Close(true,misValue,misValue);
- app.Quit();
- return true;
- }
- public bool ExcelWriteTest()
- {
-
- Application app = new Application();
- Workbook wb = app.Workbooks.Add();
- Worksheet worksheet = (Worksheet)wb.Worksheets.get_Item(1);
- worksheet.Cells[1, 1] = "测试一下";
- string filePath = @"C:\Users\刘耀文\Desktop\测试.xls";
- wb.SaveAs(filePath);
- wb.Close();
- app.Quit();
- return true;
- }*/
- }
- }
|