C#組件系列 你值得擁有的一款Excel處理神器Spire.XLS
前言:最近項(xiàng)目里面有一些對(duì)Excel操作的需求,博主想都沒(méi)想,NPOI唄,簡(jiǎn)單、開(kāi)源、免費(fèi),大家都喜歡!確實(shí),對(duì)于一些簡(jiǎn)單的Excel導(dǎo)入、導(dǎo)出、合并單元格等,它都沒(méi)啥太大的問(wèn)題,但是這次的需求有兩點(diǎn)是NPOI搞不定的:
1、導(dǎo)入Excel后,需要切割Excel的Sheet頁(yè),然后每個(gè)Sheet頁(yè)單獨(dú)生成一個(gè)PDF文件。
2、導(dǎo)出Excel的時(shí)候,項(xiàng)目里面需要將一些數(shù)據(jù)表格以圖表的形式在Excel里面展示。
找了一圈資料,對(duì)于Excel生成pdf,網(wǎng)上的答案千篇一律:使用COM組件的方式,通過(guò)調(diào)用服務(wù)器上面的Office組件里面的東西去轉(zhuǎn)。這種方式需要在服務(wù)器上面安裝Office,這倒是其次,最重要的是,權(quán)限的問(wèn)題很頭疼。博主已經(jīng)按照這種方式實(shí)現(xiàn)了,調(diào)試的時(shí)候沒(méi)問(wèn)題,部署到IIS上面之后又出了各種權(quán)限的問(wèn)題,好不容易在一臺(tái)服務(wù)器上面部署成功了,放到另一臺(tái)服務(wù)器上面按照同樣的方式部署,卻還是提示“拒絕訪問(wèn)”。博主也是醉了。而對(duì)于Excel生成圖表,NPOI暫時(shí)沒(méi)找到實(shí)現(xiàn)方式,COM組件的方式可以,但是實(shí)現(xiàn)起來(lái)略顯復(fù)雜,并且這東西龐大、不太穩(wěn)定,尤其是咱們大部分人個(gè)人電腦上面裝的Office都不是正版,使用起來(lái)也很麻煩。
基于此,經(jīng)過(guò)一番努力,找到了這么一個(gè)第三方組件Spire.XLS。這兩天體驗(yàn)了一把,使用起來(lái)還比較順手,在此來(lái)簡(jiǎn)單介紹下這個(gè)組件的使用吧。
一、組件介紹
Spire.XLS是E-iceblue開(kāi)發(fā)的一套基于企業(yè)級(jí)的專業(yè)Office文檔處理的組件之一,全稱Spire.Office for .NET。旗下有Spire.Doc,Spire XLS,Spire.PDF,Spire.BarCode等多款專業(yè)組件,為各種Office文檔在程序處理上提供了很大的方便,官方為各種功能提供了大量的在線api,簡(jiǎn)化了使用組件的難度。組件使用時(shí)不需要本地Office組件的支持。Spire.Office是一款企業(yè)級(jí)組件,它提供了收費(fèi)版本和免費(fèi)版本兩種級(jí)別,一般來(lái)說(shuō),對(duì)于個(gè)人的應(yīng)用,免費(fèi)版本已足夠用。比如對(duì)于上文博主遇到的問(wèn)題,Spire.XLS組件就提供了很好的實(shí)現(xiàn)機(jī)制,如果你也遇到了NPOI解決不了的問(wèn)題,不妨試試這個(gè)。
“XLS”是Excel文件的后綴之一,顧名思義,Spire.XLS當(dāng)然就是針對(duì)Excel表格處理的組件嘍,本篇,博主將結(jié)合上文遇到的問(wèn)題來(lái)看看Spire.XLS組件的強(qiáng)大功能。
二、組件安裝使用
對(duì)于組件的安裝,在此還是提供兩種方式:
1、官方下載安裝
下載地址。官方下載的安裝包是msi結(jié)尾的,安裝時(shí)需要選擇支持的VS版本等信息,軟件的安裝就不做過(guò)多說(shuō)明,有興趣的可以下載試試。
2、Nuget安裝
大家最喜歡的應(yīng)該還是Nuget方式吧,簡(jiǎn)單,方便,并且易于管理。博主也是不太喜歡為了一個(gè)組件而去單獨(dú)下載一個(gè)安裝包。
Spire.XLS也提供了Nuget的方式,只需要搜索Spire,選擇免費(fèi)版的組件即可:
安裝完成后自動(dòng)引用了需要的dll
三、組件功能介紹
關(guān)于Excel的一些常用操作,比如取值、賦值、設(shè)置單元格樣式等,這里就不做過(guò)多介紹,無(wú)論是Com組件、NPOI還是Aspose,這些都是最基礎(chǔ)的功能。下面就針對(duì)上文提出的幾個(gè)問(wèn)題著重說(shuō)明下。
1、Excel轉(zhuǎn)PDF
(1)COM組件實(shí)現(xiàn)思路回顧
關(guān)于Excel轉(zhuǎn)PDF的實(shí)現(xiàn),網(wǎng)上找到的解決方案基本一樣,大致代碼如此:
/// <summary>
/// 把Excel文件轉(zhuǎn)換成PDF格式文件
/// </summary>
/// <param name="sourcePath">源文件路徑</param>
/// <param name="targetPath">目標(biāo)文件路徑</param>
/// <returns>true=轉(zhuǎn)換成功</returns>
public bool XLSConvertToPDF(string sourcePath, string targetPath)
{
Logger.Info("開(kāi)始轉(zhuǎn)pdf");
bool result = false;
XlFixedFormatType targetType = XlFixedFormatType.xlTypePDF;
object missing = Type.Missing;
Microsoft.Office.Interop.Excel.Application application = null;
Microsoft.Office.Interop.Excel.Workbook workBook = null;
try
{
application = new Application();
application.Interactive = false;
object target = targetPath;
object type = targetType;
workBook = application.Workbooks.Open(sourcePath, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing, missing, missing, missing);
application.Interactive = true;
workBook.ExportAsFixedFormat(targetType, target, XlFixedFormatQuality.xlQualityStandard, true, false, missing, missing, missing, missing);
result = true;
}
catch(Exception ex)
{
Logger.Error("excel轉(zhuǎn)pdf異常,異常信息:" + ex.Message + "。堆棧信息:" + ex.StackTrace);
result = false;
}
finally
{
if (workBook != null)
{
workBook.Close(true, missing, missing);
workBook = null;
}
if (application != null)
{
application.Quit();
application = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
return result;
}
這個(gè)方法需要依賴于本機(jī)上面的office Com組件,如果你安裝Office的時(shí)候,沒(méi)有安裝com組件相關(guān)的dll,這個(gè)方法也是用不了的,并且還有一個(gè)最大的問(wèn)題就是執(zhí)行application.Workbooks.Open(sourcePath, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);這一個(gè)方法的時(shí)候需要當(dāng)前用戶有操作Excel Application這個(gè)組件的權(quán)限,尤其是部署到IIS上面之后,需要配置一系列的權(quán)限,很是麻煩。
(2)Spire.XLS實(shí)現(xiàn)轉(zhuǎn)換
通過(guò)上文,我們知道,Spire.Office提供了Spire.XLS和Spire.PDF兩個(gè)組件,那么他們之間的轉(zhuǎn)換就簡(jiǎn)單了。我們還是模擬一個(gè)文件上傳的功能。
前端有一個(gè)上傳控件:
后臺(tái)有一個(gè)接收上傳文件的方法如下:
[HttpPost]
public JsonResult UploadFile()
{
var strRes = string.Empty;
var oFile = Request.Files["txt_file"];
Workbook book = new Workbook();
book.LoadFromStream(oFile.InputStream);
var strFullName = @"D:\Data\Upload\" + "First" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
book.SaveToPdf(strFullName);
return Json(new object { }, JsonRequestBehavior.AllowGet);
}
就這么簡(jiǎn)單的幾句話即可實(shí)現(xiàn)將上傳的Excel轉(zhuǎn)成PDF文件。根據(jù)源文件生成Workbook對(duì)象,Spire.XLS提供了多種方式,我們最常用的兩種方式如下:
// 根據(jù)文件路徑生成workbook. public void LoadFromFile(string fileName); // 根據(jù)文件流生成workbook. public void LoadFromStream(Stream stream);
2.1、最原始的轉(zhuǎn)換
原始Excel文件:
轉(zhuǎn)換成PDF之后
2.2、不好看?加一個(gè)邊框即可。
轉(zhuǎn)換之后
2.3、自定義轉(zhuǎn)換的PDF
有些情況下,我們Excel里面有很多列,導(dǎo)致默認(rèn)生成的pdf換行問(wèn)題,這樣將會(huì)導(dǎo)致PDF的可讀性很差,這種情況,Spire.XLS為我們提供了自定義轉(zhuǎn)換PDF的方式,比如可以指定PDF的頁(yè)寬,頁(yè)高,大小等等屬性。
比如有如下Excel文檔需要轉(zhuǎn)換成PDF文件:
如果按照常規(guī)的轉(zhuǎn)換,生成的PDF的寬度不足以顯示Excel的所有列,于是轉(zhuǎn)換出來(lái)的效果這樣:
為了解決這種問(wèn)題,組件為我們提供了如下方法:
[HttpPost]
public JsonResult UploadFile()
{
var strRes = string.Empty;
var oFile = Request.Files["txt_file"];
Workbook book = new Workbook();
book.LoadFromStream(oFile.InputStream);
var strFullName = @"D:\Data\Upload\" + "First" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
pdfDocument.PageSettings.Width = 1800;//指定PDF的寬度
pdfDocument.PageSettings.Height = 1000;//指定PDF的高度
PdfConverterSettings settings = new PdfConverterSettings();
settings.TemplateDocument = pdfDocument;
PdfConverter pdfConverter = new PdfConverter(book);
pdfDocument = pdfConverter.Convert(settings);
pdfDocument.SaveToFile(strFullName);
return Json(new object { }, JsonRequestBehavior.AllowGet);
}
這樣就可以正常了,如果你的Excel列更多,可以適當(dāng)調(diào)整寬度和高度。得到的結(jié)果如下
還有更多強(qiáng)大的功能大家有興趣可以慢慢探索,官方文檔寫(xiě)得還算詳細(xì)。
2.4、Excel轉(zhuǎn)其他類型
除了轉(zhuǎn)為PDF,Spire.XLS還支持轉(zhuǎn)換為其他類型,比如常見(jiàn)的xml、Image、Html等。如果大家有這方面的需求,可以深究一下。
2、Excel生成圖表
2.1、Excel圖表生成原理分析
通過(guò)下面一張圖先來(lái)看看Excel里面生成圖表的原理
通過(guò)這張圖我們可以看到,Excel生成圖表首先需要當(dāng)前文檔里面存在數(shù)據(jù)表格,然后選中相應(yīng)的數(shù)據(jù)表格,最后選擇生成的圖表類型,Excel應(yīng)用會(huì)自動(dòng)幫你生成相應(yīng)的數(shù)據(jù)圖表。
2.2、Spire.XLS生成簡(jiǎn)單圖表
知道了上面Excel生成圖表的原理,我們?cè)賮?lái)看看Spire.XLS組件如何幫助我們解決生成圖表的問(wèn)題。關(guān)于生成圖表,Spire.XLS組件提供了很多的選擇,覆蓋了Excel里面各種自帶的圖表類型、統(tǒng)計(jì)方法等。下面先來(lái)看一個(gè)簡(jiǎn)單點(diǎn)的例子。
[HttpPost]
public JsonResult ExportData()
{
try
{
Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
var random = new Random();
var iCellcount = 1;
//1.設(shè)置表頭
sheet.Range[1, iCellcount++].Text = "部門名稱";
sheet.Range[1, iCellcount++].Text = "部門人數(shù)";
var lstDeptName = new List<string>() { "市場(chǎng)部", "策劃部", "公關(guān)部", "行政部", "開(kāi)發(fā)部" };
var a = 0;
//2.構(gòu)造表數(shù)據(jù)
for (var i = 2; i < 7; i++)
{
iCellcount = 1;
sheet.Range[i, iCellcount++].Text = lstDeptName[a++];
sheet.Range[i, iCellcount++].NumberValue = random.Next(1, 100); ;
}
//3.生成圖表
SetChart(sheet, ExcelChartType.BarClustered);var strFullName = @"D:\Data\Upload\" + "Export" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
book.SaveToFile(strFullName, ExcelVersion.Version2010);
}
catch (Exception ex)
{ }
return Json(true, JsonRequestBehavior.AllowGet);
}
private void SetChart(Worksheet sheet, ExcelChartType chartFormat)
{
//1.設(shè)置sheet頁(yè)的名稱
sheet.Name = "Chart data";
sheet.GridLinesVisible = false;
Chart chart = sheet.Charts.Add();
//2.指定生成圖表的區(qū)域
chart.DataRange = sheet.Range["A1:B6"];
chart.SeriesDataFromRange = false;
//3.指定圖表的所在位置
chart.LeftColumn = 5;
chart.TopRow = 2;
chart.RightColumn = 11;
chart.BottomRow = 29;
chart.ChartType = chartFormat;
//4.設(shè)置圖表的名稱以及x、y軸的名稱
chart.ChartTitle = "部門信息";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 12;
chart.PrimaryCategoryAxis.Title = "部門";
chart.PrimaryCategoryAxis.Font.IsBold = true;
chart.PrimaryCategoryAxis.TitleArea.IsBold = true;
chart.PrimaryValueAxis.Title = "人數(shù)";
chart.PrimaryValueAxis.HasMajorGridLines = false;
chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;
chart.PrimaryValueAxis.MinValue = 0;
chart.PrimaryValueAxis.TitleArea.IsBold = true;
//5.設(shè)置圖表的值
Spire.Xls.Charts.ChartSerie cs = chart.Series[0];
cs.CategoryLabels = sheet.Range["A2:A6"];
cs.Values = sheet.Range["B2:B6"];
cs.DataFormat.ShowActiveValue = true;
chart.Legend.Position = LegendPositionType.Top;
}
通過(guò)以上一段代碼得到的Excel內(nèi)容如下:
代碼釋疑:關(guān)于上面的代碼不難,但還是想做些簡(jiǎn)單的說(shuō)明。
首先填充表格數(shù)據(jù),Spire.XLS讀寫(xiě)數(shù)據(jù)表格使用的是sheet.Range[i, iCellcount++].Text這種方式。值得一提的是這里的行列索引都是從1開(kāi)始的。Range除了提供行列索引的方式,還提供了Range["B1"].Text這種方式去讀取值。
通過(guò)上文Excel生成圖表原理我們知道,出了有數(shù)據(jù)表格,還得選中生成圖表的區(qū)域,上述代碼里面通過(guò)chart.DataRange = sheet.Range["A1:B6"];這一句去指定區(qū)域,和Excel里面的操作方式保持一致。
通過(guò)chart.ChartType = chartFormat;來(lái)指定需要生成的圖表類型,Spire.XLS里面通過(guò)一個(gè)枚舉類型包含了各種圖表類型。
除了上面的這些,組件還支持指定圖表在文檔中的位置、圖表坐標(biāo)的最大值最小值。并且能夠通過(guò)
這種方式去指定分類和值的區(qū)域,更加符合Excel的操作習(xí)慣。當(dāng)然,如無(wú)特殊,這些完全可以不用指定。
2.3、對(duì)兩項(xiàng)或者多項(xiàng)進(jìn)行統(tǒng)計(jì)
上面只是一個(gè)最簡(jiǎn)單的例子,如果要對(duì)多列進(jìn)行統(tǒng)計(jì)呢?我們繼續(xù)來(lái)看這個(gè)例子,我們將代碼改成這樣:
[HttpPost]
public JsonResult ExportData()
{
try
{
Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
var random = new Random();
var iCellcount = 1;
//1.設(shè)置表頭
sheet.Range[1, iCellcount++].Text = "部門名稱";
sheet.Range[1, iCellcount++].Text = "在職人數(shù)";
sheet.Range[1, iCellcount++].Text = "離職人數(shù)";
var lstDeptName = new List<string>() { "市場(chǎng)部", "策劃部", "公關(guān)部", "行政部", "開(kāi)發(fā)部" };
var a = 0;
//2.構(gòu)造表數(shù)據(jù)
for (var i = 2; i < 7; i++)
{
iCellcount = 1;
sheet.Range[i, iCellcount++].Text = lstDeptName[a++];
sheet.Range[i, iCellcount++].NumberValue = random.Next(1, 100);
sheet.Range[i, iCellcount++].NumberValue = random.Next(1, 100); ;
}
//3.生成圖表
SetChart(sheet, ExcelChartType.BarClustered);
var strFullName = @"D:\Data\Upload\" + "Export" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
book.SaveToFile(strFullName, ExcelVersion.Version2010);
}
catch (Exception ex){}
return Json(true, JsonRequestBehavior.AllowGet);
}
private void SetChart(Worksheet sheet, ExcelChartType chartFormat)
{
//1.設(shè)置sheet頁(yè)的名稱
sheet.Name = "Chart data";
sheet.GridLinesVisible = false;
Chart chart = sheet.Charts.Add();
//2.指定生成圖表的區(qū)域
chart.DataRange = sheet.Range["A1:C6"];
chart.SeriesDataFromRange = false;
//3.指定圖表的所在位置
chart.LeftColumn = 5;
chart.TopRow = 2;
chart.RightColumn = 11;
chart.BottomRow = 29;
chart.ChartType = chartFormat;
//4.設(shè)置圖表的名稱以及x、y軸的名稱
chart.ChartTitle = "部門信息";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 12;
chart.PrimaryCategoryAxis.Title = "部門";
chart.PrimaryCategoryAxis.Font.IsBold = true;
chart.PrimaryCategoryAxis.TitleArea.IsBold = true;
chart.PrimaryValueAxis.Title = "人數(shù)";
chart.PrimaryValueAxis.HasMajorGridLines = false;
chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90;
chart.PrimaryValueAxis.MinValue = 0;
chart.PrimaryValueAxis.TitleArea.IsBold = true;
//5.設(shè)置圖表的值
Spire.Xls.Charts.ChartSerie cs = chart.Series[0];
cs.DataFormat.ShowActiveValue = true;
cs.DataFormat.ShowBubble = true;
chart.Legend.Position = LegendPositionType.Top;
}
得到結(jié)果如下:
這里唯一的變化是數(shù)據(jù)區(qū)域,只要指定我們需要生成圖表的區(qū)域是哪部分,Excel會(huì)自動(dòng)進(jìn)行計(jì)算并生成圖表。
2.4、各種類型的圖表展示
上文說(shuō)過(guò),chart.ChartType = chartFormat;這一句可以設(shè)置圖表的類型,在Spire.XLS里面定義了一系列的圖表類型:
amespace Spire.Xls
{
// 摘要:
// Chart types.
public enum ExcelChartType
{
// 摘要:
// Represents the column clustered chart type.
ColumnClustered = 0,
//
// 摘要:
// Represents the stacked column chart type.
ColumnStacked = 1,
//
// 摘要:
// Represents the 100% stacked column chart type.
Column100PercentStacked = 2,
//
// 摘要:
// Represents the 3D clustered column chart type.
Column3DClustered = 3,
//
// 摘要:
// Represents the 3D stacked column chart type.
Column3DStacked = 4,
//
// 摘要:
// Represents the 3D 100% stacked column chart type.
Column3D100PercentStacked = 5,
//
// 摘要:
// Represents the 3D column chart type.
Column3D = 6,
//
// 摘要:
// Represents the clustered bar chart type.
BarClustered = 7,
//
// 摘要:
// Represents the stacked bar chart type.
BarStacked = 8,
//
// 摘要:
// Represents the 100% stacked bar chart type.
Bar100PercentStacked = 9,
//
// 摘要:
// Represents the 3D clustered bar chart type.
Bar3DClustered = 10,
//
// 摘要:
// Represents the 3D stacked bar chart type.
Bar3DStacked = 11,
//
// 摘要:
// Represents the 100% 3D stacked bar chart type.
Bar3D100PercentStacked = 12,
//
// 摘要:
// Represents the Line chart type.
Line = 13,
//
// 摘要:
// Represents the stacked line chart type.
LineStacked = 14,
//
// 摘要:
// Represents the 100% stacked line chart type.
Line100PercentStacked = 15,
//
// 摘要:
// Represents the markers line chart type.
LineMarkers = 16,
//
// 摘要:
// Represents the stacked markers line chart type.
LineMarkersStacked = 17,
//
// 摘要:
// Represents the 100% stacked markers line chart type.
LineMarkers100PercentStacked = 18,
//
// 摘要:
// Represents the 3D line chart type.
Line3D = 19,
//
// 摘要:
// Represents the pie chart type.
Pie = 20,
//
// 摘要:
// Represents the 3D pie chart type.
Pie3D = 21,
//
// 摘要:
// Represents the pie of pie chart type.
PieOfPie = 22,
//
// 摘要:
// Represents the exploded pie chart type.
PieExploded = 23,
//
// 摘要:
// Represents the 3D exploded pie chart type.
Pie3DExploded = 24,
//
// 摘要:
// Represents the bar pie chart type.
PieBar = 25,
//
// 摘要:
// Represents the markers scatter chart type.
ScatterMarkers = 26,
//
// 摘要:
// Represents the ScatterSmoothedLineMarkers chart type.
ScatterSmoothedLineMarkers = 27,
//
// 摘要:
// Represents the ScatterSmoothedLine chart type.
ScatterSmoothedLine = 28,
//
// 摘要:
// Represents the ScatterLineMarkers chart type.
ScatterLineMarkers = 29,
//
// 摘要:
// Represents the ScatterLine chart type.
ScatterLine = 30,
//
// 摘要:
// Represents the Area chart type.
Area = 31,
//
// 摘要:
// Represents the AreaStacked chart type.
AreaStacked = 32,
//
// 摘要:
// Represents the Area100PercentStacked chart type.
Area100PercentStacked = 33,
//
// 摘要:
// Represents the Area3D chart type.
Area3D = 34,
//
// 摘要:
// Represents the Area3DStacked chart type.
Area3DStacked = 35,
//
// 摘要:
// Represents the Area3D100PercentStacked chart type.
Area3D100PercentStacked = 36,
//
// 摘要:
// Represents the Doughnut chart type.
Doughnut = 37,
//
// 摘要:
// Represents the DoughnutExploded chart type.
DoughnutExploded = 38,
//
// 摘要:
// Represents the Radar chart type.
Radar = 39,
//
// 摘要:
// Represents the RadarMarkers chart type.
RadarMarkers = 40,
//
// 摘要:
// Represents the RadarFilled chart type.
RadarFilled = 41,
//
// 摘要:
// Represents the Surface3D chart type.
Surface3D = 42,
//
// 摘要:
// Represents the Surface3DNoColor chart type.
Surface3DNoColor = 43,
//
// 摘要:
// Represents the SurfaceContour chart type.
SurfaceContour = 44,
//
// 摘要:
// Represents the SurfaceContourNoColor chart type.
SurfaceContourNoColor = 45,
//
// 摘要:
// Represents the Bubble chart type.
Bubble = 46,
//
// 摘要:
// Represents the Bubble3D chart type.
Bubble3D = 47,
//
// 摘要:
// Represents the StockHighLowClose chart type.
StockHighLowClose = 48,
//
// 摘要:
// Represents the StockOpenHighLowClose chart type.
StockOpenHighLowClose = 49,
//
// 摘要:
// Represents the StockVolumeHighLowClose chart type.
StockVolumeHighLowClose = 50,
//
// 摘要:
// Represents the StockVolumeOpenHighLowClose chart type.
StockVolumeOpenHighLowClose = 51,
//
// 摘要:
// Represents the CylinderClustered chart type.
CylinderClustered = 52,
//
// 摘要:
// Represents the CylinderStacked chart type.
CylinderStacked = 53,
//
// 摘要:
// Represents the Cylinder100PercentStacked chart type.
Cylinder100PercentStacked = 54,
//
// 摘要:
// Represents the CylinderBarClustered chart type.
CylinderBarClustered = 55,
//
// 摘要:
// Represents the CylinderBarStacked chart type.
CylinderBarStacked = 56,
//
// 摘要:
// Represents the CylinderBar100PercentStacked chart type.
CylinderBar100PercentStacked = 57,
//
// 摘要:
// Represents the Cylinder3DClustered chart type.
Cylinder3DClustered = 58,
//
// 摘要:
// Represents the ConeClustered chart type.
ConeClustered = 59,
//
// 摘要:
// Represents the ConeStacked chart type.
ConeStacked = 60,
//
// 摘要:
// Represents the Cone100PercentStacked chart type.
Cone100PercentStacked = 61,
//
// 摘要:
// Represents the ConeBarClustered chart type.
ConeBarClustered = 62,
//
// 摘要:
// Represents the ConeBarStacked chart type.
ConeBarStacked = 63,
//
// 摘要:
// Represents the ConeBar100PercentStacked chart type.
ConeBar100PercentStacked = 64,
//
// 摘要:
// Represents the Cone3DClustered chart type.
Cone3DClustered = 65,
//
// 摘要:
// Represents the PyramidClustered chart type.
PyramidClustered = 66,
//
// 摘要:
// Represents the PyramidStacked chart type.
PyramidStacked = 67,
//
// 摘要:
// Represents the Pyramid100PercentStacked chart type.
Pyramid100PercentStacked = 68,
//
// 摘要:
// Represents the PyramidBarClustered chart type.
PyramidBarClustered = 69,
//
// 摘要:
// Represents the PyramidBarStacked chart type.
PyramidBarStacked = 70,
//
// 摘要:
// Represents the PyramidBar100PercentStacked chart type.
PyramidBar100PercentStacked = 71,
//
// 摘要:
// Represents the Pyramid3DClustered chart type.
Pyramid3DClustered = 72,
//
// 摘要:
// Represents the CombinationChart chart types.
CombinationChart = 73,
}
}
我們來(lái)看看一些比較常見(jiàn)的圖表
2.4.1、餅狀圖
ExcelChartType.Pie
ExcelChartType.Pie3D
2.4.2、連線圖
ExcelChartType.Line3D
ExcelChartType.LineStacked
2.4.3、區(qū)域圖
2.4.4、雷達(dá)圖
2.4.5、圓形柱狀圖
3、其他功能介紹
關(guān)于Spire.XLS的其他亮點(diǎn)功能,博主也還在研究,已經(jīng)知道的一些常用功能比如(1)支持單元格合并、凍結(jié)、注釋;(2)數(shù)據(jù)庫(kù)方式的導(dǎo)入導(dǎo)出;(3)Sheet頁(yè)的復(fù)制、切割、顯示、隱藏等;(4)頁(yè)眉頁(yè)腳的設(shè)置;(5)數(shù)據(jù)的分組、排序;(6)像Excel插入圖片,設(shè)置圖片樣式等。這些功能有些已經(jīng)實(shí)現(xiàn),有些還在研究,等以后有機(jī)會(huì)再發(fā)出來(lái)供大家參考。因?yàn)槠鶈?wèn)題,這篇先到這里吧。
四、總結(jié)
以上簡(jiǎn)單總結(jié)了下Spire.XLS組件幾個(gè)特色功能,很好的解決了博主遇到的問(wèn)題,博主覺(jué)得在一定程度上,Spire.XLS組件能擬補(bǔ)NPOI、COM組件的部分不足。還有很多其他特色功能待以后整理之后連帶測(cè)試Demo一起發(fā)出。如果你也遇到一些其他組件解決不了的問(wèn)題,不妨試試它,或許會(huì)帶給你驚喜。當(dāng)然,如果本文能夠幫到你,還是希望園友們幫忙推薦,博主下次繼續(xù)努力!
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。
上一篇:C#如何給PDF文件添加水印
欄 目:C#教程
下一篇:利用WCF雙工模式實(shí)現(xiàn)即時(shí)通訊
本文標(biāo)題:C#組件系列 你值得擁有的一款Excel處理神器Spire.XLS
本文地址:http://www.jygsgssxh.com/a1/C_jiaocheng/6250.html
您可能感興趣的文章
- 01-10C#獲取動(dòng)態(tài)生成的CheckBox值
- 01-10C#編程和Visual Studio使用技巧(下)
- 01-10C#操作LINQ to SQL組件進(jìn)行數(shù)據(jù)庫(kù)建模的基本教程
- 01-10C#進(jìn)階系列 WebApi身份認(rèn)證解決方案推薦:Basic基礎(chǔ)認(rèn)證
- 01-10C#線程處理系列之線程池中的I/O線程
- 01-10適用于WebForm Mvc的Pager分頁(yè)組件C#實(shí)現(xiàn)
- 01-10C# 設(shè)計(jì)模式系列教程-簡(jiǎn)單工廠模式
- 01-10C# 設(shè)計(jì)模式系列教程-外觀模式
- 01-10C# 設(shè)計(jì)模式系列教程-命令模式
- 01-10C# 設(shè)計(jì)模式系列教程-模板方法模式


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10C#通過(guò)反射獲取當(dāng)前工程中所有窗體并
- 01-10關(guān)于ASP網(wǎng)頁(yè)無(wú)法打開(kāi)的解決方案
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10C#實(shí)現(xiàn)txt定位指定行完整實(shí)例
- 01-10WinForm實(shí)現(xiàn)仿視頻播放器左下角滾動(dòng)新
- 01-10C#停止線程的方法
- 01-10C#實(shí)現(xiàn)清空回收站的方法
- 01-10C#通過(guò)重寫(xiě)Panel改變邊框顏色與寬度的
- 01-10C#實(shí)現(xiàn)讀取注冊(cè)表監(jiān)控當(dāng)前操作系統(tǒng)已
隨機(jī)閱讀
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10delphi制作wav文件的方法
- 01-11Mac OSX 打開(kāi)原生自帶讀寫(xiě)NTFS功能(圖文
- 04-02jquery與jsp,用jquery
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 01-10C#中split用法實(shí)例總結(jié)
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置


