qq_17031883 2024-02-29 15:44 采纳率: 36.4%
浏览 31
已结题

html 表格编辑器,表格编辑器

.net core mvc 怎么做类似病例表格编辑器,记录每天病人体征参数,可以编辑,新增,打印,导出,能读取表格内容变化,如能帮做出费用可增加,最好有案列

img


img

  • 写回答

22条回答 默认 最新

  • 百锦再@新空间创想科技 优质创作者: 编程框架技术领域 2024-02-29 15:45
    关注
    获得0.90元问题酬金

    using System;
    using System.Collections.Generic;
    using System.IO;
    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Spreadsheet;

    namespace YourNamespace{public class ExcelGenerator{public static void GenerateExcel(List<
    Patient>
    patients){string filePath = "
    PatientsData.xlsx"
    ;

    using (SpreadsheetDocument document = SpreadsheetDocument.Create(filePath, SpreadsheetDocumentType.Workbook)){WorkbookPart workbookPart = document.AddWorkbookPart();
    workbookPart.Workbook = new Workbook();

    WorksheetPart worksheetPart = workbookPart.AddNewPart<
    WorksheetPart>
    ();
    SheetData sheetData = new SheetData();
    worksheetPart.Worksheet = new Worksheet(sheetData);

    Sheets sheets = workbookPart.Workbook.AppendChild(new Sheets());
    Sheet sheet = new Sheet() { Id = workbookPart.GetIdOfPart(worksheetPart), SheetId = 1, Name = "
    PatientsData"
    };
    sheets.Append(sheet);

    Row headerRow = new Row();
    headerRow.Append(CreateCell("
    Patient ID"
    ));
    headerRow.Append(CreateCell("
    Name"
    ));
    headerRow.Append(CreateCell("
    Temperature"
    ));
    headerRow.Append(CreateCell("
    Blood Pressure"
    ));

    sheetData.AppendChild(headerRow);

    foreach (var patient in patients){Row dataRow = new Row();
    dataRow.Append(CreateCell(patient.PatientId));
    dataRow.Append(CreateCell(patient.Name));
    dataRow.Append(CreateCell(patient.Temperature));
    dataRow.Append(CreateCell(patient.BloodPressure));

    sheetData.AppendChild(dataRow);
    }
    workbookPart.Workbook.Save();
    }}
    private static Cell CreateCell(string text){Cell cell = new Cell();
    cell.DataType = CellValues.String;
    cell.CellValue = new CellValue(text);

    return cell;
    }}
    public class Patient{public int PatientId { get;
    set;
    }public string Name { get;
    set;
    }public decimal Temperature { get;
    set;
    }public string BloodPressure { get;
    set;
    }}}

    这段代码演示了如何使用DocumentFormat.OpenXml库生成一个Excel文件,其中记录了每天不同病人的体征参数(例子中包括PatientId、Name、Temperature和BloodPressure)。可以根据实际情况修改字段和内容。


    有问题你别着急,评论留言都可以,看到马上就回复,尽量及时补充齐
    评论

报告相同问题?

问题事件

  • 系统已结题 3月8日
  • 修改了问题 3月5日
  • 赞助了问题酬金15元 3月2日
  • 修改了问题 3月2日
  • 展开全部