2017-09-27 80 views
0

我正在用c#開發並使用EPPLUS庫創建Excel表,特別是 我創建了餅圖,其中我也顯示零值,但是我想刪除它們。我一直無法找到任何解決方法。下面的代碼我使用:如何使用EPPLUS庫在餅圖中隱藏零值

<pre> int chart_RegionHeaderRow = 1; 
int chart_RegionHeaderColumn = 13; 
firstRowCategory = 2; 
lastRowCategory = 2; 
firstColCategory = 3; 
lastColCategory = firstColCategory + pDeployVersionSet.Length - 1; 

int firstColValue = 3; 
int lastColValue = firstColValue + pDeployVersionSet.Length - 1; 
int firstRowSerie = 3; 

int rowCR = chart_RegionHeaderRow; 
int colCR = chart_RegionHeaderColumn; 

int chart_RegionColStep = 6; 
int chart_RegionRowStep = 16; 

//Create the Region chart WW 
var chartWW = (ExcelPieChart)worksheet.Drawings.AddChart("pieChartDeployWW", eChartType.Pie); 
chartWW.SetSize(300, 300); 
chartWW.SetPosition(rowCR, 0, colCR, 0); 
chartWW.Title.Text = "WW"; 

chartWW.DataLabel.ShowValue = true; 
chartWW.DataLabel.ShowPercent = true; 
chartWW.DataLabel.ShowLeaderLines = true; 
indexSerie = firstRowSerie; 
chartWW.Series.Add(ExcelRange.GetAddress(indexSerie + _RegionsSet.Length, 
    firstColValue, 
    indexSerie + _RegionsSet.Length, 
    lastColValue), 
     ExcelRange.GetAddress(firstRowCategory, firstColCategory, lastRowCategory, lastColCategory <code> 

,也是導致Excel文件:

enter image description here

我希望有人可以給我方向。 謝謝

+2

歡迎來到Stackoverflow。你能分享一些代碼嗎?看看這個鏈接指導如何提出問題https://stackoverflow.com/help/how-to-ask – gareththegeek

回答

0

我的圖表數據是從導入空格爲文本的.csv文件導入的。 這幫助我擺脫了我的圖表上的零值。

sheet.Cells["B33"].Clear(); 

我的圖表是折線圖,但它也可能適用於您。

+0

它不起作用,請嘗試檢查我發佈的代碼和結果。謝謝 – Paolo

相關問題