小编You*_*nes的帖子

使用openxml创建LineChart

我正在尝试在Excel工作表上创建一个新的LineChart,我不知道如何在这个图表上感受数据以及如何为每个系列添加值.以下是我尝试做的事情:

    static void Main(string[] args)
    {
        string docName = @"myFile.xlsx";
        string worksheetName = "Sheet1";
        string title = "My Chart";
        InsertChartInSpreadsheet(docName, worksheetName, title);
    }


    private static void InsertChartInSpreadsheet(string docName, string worksheetName, string title)
    {

    // Open Document for editing
        using (SpreadsheetDocument document = SpreadsheetDocument.Open(docName, true))
        {
            IEnumerable<Sheet> sheets = document.WorkbookPart.Workbook.Descendants<Sheet>().
    Where(s => s.Name == worksheetName);
            if (sheets.Count() == 0)
            {
                // The specified worksheet does not exist.
                return;
            }

            WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheets.First().Id);

            // Add a new drawing to the worksheet. …
Run Code Online (Sandbox Code Playgroud)

.net c# charts linechart openxml

5
推荐指数
1
解决办法
6388
查看次数

Java/C三元运算符

我想将一个代码从if条件转换为三元条件,首先我成功地转换了一个条件,如:

    int minutes=59,hours=23;
// 1) if condition
if (minutes<59)
    minutes++;
else
    minutes=0;

// 2) ternary condition
minutes = (minutes < 59) ? minutes+1  :  0;
Run Code Online (Sandbox Code Playgroud)

现在的问题是当我有多个值来编辑它时,例如:

    int minutes=59,hours=23;
// if condition
if (minutes<59)
    minutes++;
else
{
    minutes = 0;
    if (hours<23)
        hours++;
    else 
        hours=0;
}
Run Code Online (Sandbox Code Playgroud)

你如何看待三元条件?谢谢 :)

c java conditional-statements

0
推荐指数
1
解决办法
680
查看次数

标签 统计

.net ×1

c ×1

c# ×1

charts ×1

conditional-statements ×1

java ×1

linechart ×1

openxml ×1