public static OrderLabel GetModel() { OrderLabel orderLable = new OrderLabel(); orderLable.PatName = "张小三"; orderLable.PatSex = "男"; orderLable.IpNo = "234334"; orderLable.PatAge = "12岁"; orderLable.BedNo = "01床"; orderLable.ItemList = new List <Item> { new Item { ItemName = "王老吉", Quantity = "250ML" }, new Item { ItemName = "清补凉", Quantity = "一包" } }; orderLable.QrCode = ImageToBytes(Image.FromFile("Images/qrCode.png")); orderLable.Freq = "bid"; orderLable.Seq = "①"; orderLable.ExecDate = "2017-07-25"; orderLable.UsageName = "静脉滴注"; return(orderLable); }
private void btnOutput_Click(object sender, EventArgs e) { var saveFileDlg = new SaveFileDialog { Filter = Resources.SaveFileFilter }; if (DialogResult.OK.Equals(saveFileDlg.ShowDialog())) { var workbookParameterContainer = new WorkbookParameterContainer(); workbookParameterContainer.Load(@"Template\orderlabel.xml"); var sheetParameterContainer = workbookParameterContainer["Sheet1"]; OrderLabel orderLabel = OrderLabelLogic.GetModel(); //执行单信息 SheetFormatter orderInfo = new SheetFormatter("Sheet1", new CellFormatter(sheetParameterContainer["PatName"], orderLabel.PatName), new CellFormatter(sheetParameterContainer["PatSex"], orderLabel.PatSex), new CellFormatter(sheetParameterContainer["IpNo"], orderLabel.IpNo), new CellFormatter(sheetParameterContainer["PatAge"], orderLabel.PatAge), new CellFormatter(sheetParameterContainer["BedNo"], orderLabel.BedNo), new CellFormatter(sheetParameterContainer["QrCode"], orderLabel.QrCode), new CellFormatter(sheetParameterContainer["Freq"], orderLabel.Freq), new CellFormatter(sheetParameterContainer["Seq"], orderLabel.Seq), new CellFormatter(sheetParameterContainer["ExecDate"], orderLabel.ExecDate), new CellFormatter(sheetParameterContainer["UsageName"], orderLabel.UsageName)); //执行单中医嘱项目 SheetFormatter itemList = new SheetFormatter("Sheet1", new TableFormatter <Item>(sheetParameterContainer["ItemName"], orderLabel.ItemList, new CellFormatter <Item>(sheetParameterContainer["ItemName"], t => t.ItemName), new CellFormatter <Item>(sheetParameterContainer["Quantity"], t => t.Quantity))); ExportHelper.ExportToLocal(@"Template\orderlabel.xlsx", saveFileDlg.FileName, orderInfo, itemList); } }