欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#組件系列 你值得擁有的一款Excel處理神器Spire.XLS

 更新時間:2016年09月22日 14:36:40   作者:懶得安分  
又一款Excel處理神器Spire.XLS,這篇文章主要為大家詳細介紹了第三方組件Spire.XLS,具有一定的參考價值,感興趣的小伙伴們可以參考一下

前言:最近項目里面有一些對Excel操作的需求,博主想都沒想,NPOI唄,簡單、開源、免費,大家都喜歡!確實,對于一些簡單的Excel導(dǎo)入、導(dǎo)出、合并單元格等,它都沒啥太大的問題,但是這次的需求有兩點是NPOI搞不定的:

1、導(dǎo)入Excel后,需要切割Excel的Sheet頁,然后每個Sheet頁單獨生成一個PDF文件。

2、導(dǎo)出Excel的時候,項目里面需要將一些數(shù)據(jù)表格以圖表的形式在Excel里面展示。

找了一圈資料,對于Excel生成pdf,網(wǎng)上的答案千篇一律:使用COM組件的方式,通過調(diào)用服務(wù)器上面的Office組件里面的東西去轉(zhuǎn)。這種方式需要在服務(wù)器上面安裝Office,這倒是其次,最重要的是,權(quán)限的問題很頭疼。博主已經(jīng)按照這種方式實現(xiàn)了,調(diào)試的時候沒問題,部署到IIS上面之后又出了各種權(quán)限的問題,好不容易在一臺服務(wù)器上面部署成功了,放到另一臺服務(wù)器上面按照同樣的方式部署,卻還是提示“拒絕訪問”。博主也是醉了。而對于Excel生成圖表,NPOI暫時沒找到實現(xiàn)方式,COM組件的方式可以,但是實現(xiàn)起來略顯復(fù)雜,并且這東西龐大、不太穩(wěn)定,尤其是咱們大部分人個人電腦上面裝的Office都不是正版,使用起來也很麻煩。

基于此,經(jīng)過一番努力,找到了這么一個第三方組件Spire.XLS。這兩天體驗了一把,使用起來還比較順手,在此來簡單介紹下這個組件的使用吧。

一、組件介紹

Spire.XLS是E-iceblue開發(fā)的一套基于企業(yè)級的專業(yè)Office文檔處理的組件之一,全稱Spire.Office for .NET。旗下有Spire.Doc,Spire XLS,Spire.PDF,Spire.BarCode等多款專業(yè)組件,為各種Office文檔在程序處理上提供了很大的方便,官方為各種功能提供了大量的在線api,簡化了使用組件的難度。組件使用時不需要本地Office組件的支持。Spire.Office是一款企業(yè)級組件,它提供了收費版本和免費版本兩種級別,一般來說,對于個人的應(yīng)用,免費版本已足夠用。比如對于上文博主遇到的問題,Spire.XLS組件就提供了很好的實現(xiàn)機制,如果你也遇到了NPOI解決不了的問題,不妨試試這個。

“XLS”是Excel文件的后綴之一,顧名思義,Spire.XLS當(dāng)然就是針對Excel表格處理的組件嘍,本篇,博主將結(jié)合上文遇到的問題來看看Spire.XLS組件的強大功能。

二、組件安裝使用

對于組件的安裝,在此還是提供兩種方式:

1、官方下載安裝

下載地址。官方下載的安裝包是msi結(jié)尾的,安裝時需要選擇支持的VS版本等信息,軟件的安裝就不做過多說明,有興趣的可以下載試試。

2、Nuget安裝

大家最喜歡的應(yīng)該還是Nuget方式吧,簡單,方便,并且易于管理。博主也是不太喜歡為了一個組件而去單獨下載一個安裝包。

Spire.XLS也提供了Nuget的方式,只需要搜索Spire,選擇免費版的組件即可:

安裝完成后自動引用了需要的dll

三、組件功能介紹

關(guān)于Excel的一些常用操作,比如取值、賦值、設(shè)置單元格樣式等,這里就不做過多介紹,無論是Com組件、NPOI還是Aspose,這些都是最基礎(chǔ)的功能。下面就針對上文提出的幾個問題著重說明下。

1、Excel轉(zhuǎn)PDF

(1)COM組件實現(xiàn)思路回顧

關(guān)于Excel轉(zhuǎn)PDF的實現(xiàn),網(wǎng)上找到的解決方案基本一樣,大致代碼如此:

/// <summary>
   /// 把Excel文件轉(zhuǎn)換成PDF格式文件 
   /// </summary>
   /// <param name="sourcePath">源文件路徑</param>
   /// <param name="targetPath">目標文件路徑</param>
   /// <returns>true=轉(zhuǎn)換成功</returns>
  public bool XLSConvertToPDF(string sourcePath, string targetPath)
  {
   Logger.Info("開始轉(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;
  }

這個方法需要依賴于本機上面的office Com組件,如果你安裝Office的時候,沒有安裝com組件相關(guān)的dll,這個方法也是用不了的,并且還有一個最大的問題就是執(zhí)行application.Workbooks.Open(sourcePath, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);這一個方法的時候需要當(dāng)前用戶有操作Excel Application這個組件的權(quán)限,尤其是部署到IIS上面之后,需要配置一系列的權(quán)限,很是麻煩。

(2)Spire.XLS實現(xiàn)轉(zhuǎn)換

通過上文,我們知道,Spire.Office提供了Spire.XLS和Spire.PDF兩個組件,那么他們之間的轉(zhuǎn)換就簡單了。我們還是模擬一個文件上傳的功能。

前端有一個上傳控件:

復(fù)制代碼 代碼如下:
<input type="file" name="txt_file" />

后臺有一個接收上傳文件的方法如下:

[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);
  }

就這么簡單的幾句話即可實現(xiàn)將上傳的Excel轉(zhuǎn)成PDF文件。根據(jù)源文件生成Workbook對象,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、不好看?加一個邊框即可。

轉(zhuǎn)換之后

2.3、自定義轉(zhuǎn)換的PDF

有些情況下,我們Excel里面有很多列,導(dǎo)致默認生成的pdf換行問題,這樣將會導(dǎo)致PDF的可讀性很差,這種情況,Spire.XLS為我們提供了自定義轉(zhuǎn)換PDF的方式,比如可以指定PDF的頁寬,頁高,大小等等屬性。

比如有如下Excel文檔需要轉(zhuǎn)換成PDF文件:

如果按照常規(guī)的轉(zhuǎn)換,生成的PDF的寬度不足以顯示Excel的所有列,于是轉(zhuǎ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é)果如下

還有更多強大的功能大家有興趣可以慢慢探索,官方文檔寫得還算詳細。

2.4、Excel轉(zhuǎn)其他類型

除了轉(zhuǎn)為PDF,Spire.XLS還支持轉(zhuǎn)換為其他類型,比如常見的xml、Image、Html等。如果大家有這方面的需求,可以深究一下。

2、Excel生成圖表

2.1、Excel圖表生成原理分析

通過下面一張圖先來看看Excel里面生成圖表的原理

通過這張圖我們可以看到,Excel生成圖表首先需要當(dāng)前文檔里面存在數(shù)據(jù)表格,然后選中相應(yīng)的數(shù)據(jù)表格,最后選擇生成的圖表類型,Excel應(yīng)用會自動幫你生成相應(yīng)的數(shù)據(jù)圖表。

2.2、Spire.XLS生成簡單圖表

知道了上面Excel生成圖表的原理,我們再來看看Spire.XLS組件如何幫助我們解決生成圖表的問題。關(guān)于生成圖表,Spire.XLS組件提供了很多的選擇,覆蓋了Excel里面各種自帶的圖表類型、統(tǒng)計方法等。下面先來看一個簡單點的例子。

[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>() { "市場部", "策劃部", "公關(guān)部", "行政部", "開發(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頁的名稱
      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;
    }

通過以上一段代碼得到的Excel內(nèi)容如下:

代碼釋疑:關(guān)于上面的代碼不難,但還是想做些簡單的說明。

首先填充表格數(shù)據(jù),Spire.XLS讀寫數(shù)據(jù)表格使用的是sheet.Range[i, iCellcount++].Text這種方式。值得一提的是這里的行列索引都是從1開始的。Range除了提供行列索引的方式,還提供了Range["B1"].Text這種方式去讀取值。

通過上文Excel生成圖表原理我們知道,出了有數(shù)據(jù)表格,還得選中生成圖表的區(qū)域,上述代碼里面通過chart.DataRange = sheet.Range["A1:B6"];這一句去指定區(qū)域,和Excel里面的操作方式保持一致。

通過chart.ChartType = chartFormat;來指定需要生成的圖表類型,Spire.XLS里面通過一個枚舉類型包含了各種圖表類型。

除了上面的這些,組件還支持指定圖表在文檔中的位置、圖表坐標的最大值最小值。并且能夠通過

復(fù)制代碼 代碼如下:
Spire.Xls.Charts.ChartSerie cs = chart.Series[0];cs.CategoryLabels = sheet.Range["A2:A6"];cs.Values = sheet.Range["B2:B6"];

這種方式去指定分類和值的區(qū)域,更加符合Excel的操作習(xí)慣。當(dāng)然,如無特殊,這些完全可以不用指定。

2.3、對兩項或者多項進行統(tǒng)計

上面只是一個最簡單的例子,如果要對多列進行統(tǒng)計呢?我們繼續(xù)來看這個例子,我們將代碼改成這樣:

[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>() { "市場部", "策劃部", "公關(guān)部", "行政部", "開發(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頁的名稱
      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會自動進行計算并生成圖表。

2.4、各種類型的圖表展示

上文說過,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,
  }
}

我們來看看一些比較常見的圖表

2.4.1、餅狀圖

ExcelChartType.Pie

ExcelChartType.Pie3D

2.4.2、連線圖

ExcelChartType.Line3D

ExcelChartType.LineStacked

2.4.3、區(qū)域圖

2.4.4、雷達圖

2.4.5、圓形柱狀圖

3、其他功能介紹

關(guān)于Spire.XLS的其他亮點功能,博主也還在研究,已經(jīng)知道的一些常用功能比如(1)支持單元格合并、凍結(jié)、注釋;(2)數(shù)據(jù)庫方式的導(dǎo)入導(dǎo)出;(3)Sheet頁的復(fù)制、切割、顯示、隱藏等;(4)頁眉頁腳的設(shè)置;(5)數(shù)據(jù)的分組、排序;(6)像Excel插入圖片,設(shè)置圖片樣式等。這些功能有些已經(jīng)實現(xiàn),有些還在研究,等以后有機會再發(fā)出來供大家參考。因為篇幅問題,這篇先到這里吧。

四、總結(jié)

以上簡單總結(jié)了下Spire.XLS組件幾個特色功能,很好的解決了博主遇到的問題,博主覺得在一定程度上,Spire.XLS組件能擬補NPOI、COM組件的部分不足。還有很多其他特色功能待以后整理之后連帶測試Demo一起發(fā)出。如果你也遇到一些其他組件解決不了的問題,不妨試試它,或許會帶給你驚喜。當(dāng)然,如果本文能夠幫到你,還是希望園友們幫忙推薦,博主下次繼續(xù)努力!

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#實現(xiàn)winform版飛行棋

    C#實現(xiàn)winform版飛行棋

    這篇文章主要為大家詳細介紹了C#實現(xiàn)winform版飛行,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • C#實現(xiàn)偽裝文件夾功能

    C#實現(xiàn)偽裝文件夾功能

    這篇文章主要為大家詳細介紹了如何利用C#實現(xiàn)偽裝文件夾的功能,文中的示例代碼講解詳細,對我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下
    2022-12-12
  • C#串口通信工具類的封裝

    C#串口通信工具類的封裝

    這篇文章主要為大家詳細介紹了C#串口通信工具類封裝,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • 小菜編程成長記(一 面試受挫——代碼無錯就是好?)

    小菜編程成長記(一 面試受挫——代碼無錯就是好?)

    小菜編程成長記(一 面試受挫——代碼無錯就是好?)...
    2006-10-10
  • c# Process.Start()找不到系統(tǒng)文件的解決方法

    c# Process.Start()找不到系統(tǒng)文件的解決方法

    vs1027在X64應(yīng)用程序下執(zhí)行process.start()時,OK;但是在X86應(yīng)用程序下執(zhí)行process.start(),報錯:找不到系統(tǒng)文件,本文就詳細的介紹一下解決方法,感興趣的可以了解一下
    2023-09-09
  • CefSharp如何進行頁面的縮放(Ctrl+滾輪)

    CefSharp如何進行頁面的縮放(Ctrl+滾輪)

    CefSharp簡單來說就是一款.Net編寫的瀏覽器包,本文主要介紹了CefSharp如何進行頁面的縮放,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-06-06
  • C# 實現(xiàn)在當(dāng)前目錄基礎(chǔ)上找到上一層目錄

    C# 實現(xiàn)在當(dāng)前目錄基礎(chǔ)上找到上一層目錄

    這篇文章主要介紹了C# 實現(xiàn)在當(dāng)前目錄基礎(chǔ)上找到上一層目錄,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-01-01
  • Unity Shader模擬玻璃效果

    Unity Shader模擬玻璃效果

    這篇文章主要為大家詳細介紹了Unity Shader模擬玻璃效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-05-05
  • C#將時間轉(zhuǎn)成文件名使用方法

    C#將時間轉(zhuǎn)成文件名使用方法

    C#將時間轉(zhuǎn)成文件名用到的是DateTime類的ToFileTime方法,下面看使用方法吧
    2014-01-01
  • C#簡單聊天室雛形

    C#簡單聊天室雛形

    這篇文章主要為大家詳細介紹了C#簡單聊天室雛形,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02

最新評論