Spire.XLS for .NET is a professional Excel .NET component that can be used to any type of .NET 2.0, 3.5, 4.0 or 4.5 framework application, both ASP.NET web sites and Windows Forms application.

Tue Jan 18, 2011 2:14 am

Hi,

I want to create at least 5 spreadsheets in excel file, could you please tell me how to do it with Spire.XLS for .NET?

thx

lilyed72
 
Posts: 5
Joined: Mon Dec 27, 2010 1:24 am

Tue Jan 18, 2011 7:19 am

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
workbook.Worksheets.Add("sheet2");
workbook.Worksheets.Add("sheet3");
workbook.Worksheets.Add("sheet4");
workbook.Worksheets.Add("sheet5");

:P
e-iceblue support
User avatar

iceblue support
 
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Thu May 14, 2015 6:43 am

Hi,

How do I add two or more chart object graph in a single work sheet in excel?

clarosian
 
Posts: 1
Joined: Wed May 13, 2015 1:26 am

Fri May 15, 2015 1:22 am

Hello,

Thanks for your inquiry.
There is some code for your reference:
Code: Select all
          //Create a new workbook
            Workbook workbook = new Workbook();

            //Initialize worksheet
            workbook.CreateEmptySheets(1);
            Worksheet sheet = workbook.Worksheets[0];

            //Year
            sheet.Range["A1"].Value = "Year";
            sheet.Range["A2"].Value = "2002";
            sheet.Range["A3"].Value = "2003";
            sheet.Range["A4"].Value = "2004";
            sheet.Range["A5"].Value = "2005";

            //Sales
            sheet.Range["B1"].Value = "Sales";
            sheet.Range["B2"].NumberValue = 4000;
            sheet.Range["B3"].NumberValue = 6000;
            sheet.Range["B4"].NumberValue = 7000;
            sheet.Range["B5"].NumberValue = 8500;
           
            //Set sheet name
            sheet.Name = "Chart data";

            Chart chart = sheet.Charts.Add(ExcelChartType.Pie3D);
            chart.DataRange = sheet.Range["B2:B5"];
            chart.SeriesDataFromRange = false;
            chart.LeftColumn = 1;
            chart.TopRow = 6;
            chart.RightColumn = 9;
            chart.BottomRow = 25;
            chart.ChartTitle = "Sales by year";
            chart.ChartTitleArea.IsBold = true;
            chart.ChartTitleArea.Size = 12;
            Spire.Xls.Charts.ChartSerie cs = chart.Series[0];
            cs.CategoryLabels = sheet.Range["A2:A5"];
         
            //Add a new  chart1
       Chart chart1 = sheet.Charts.Add();
            chart1.ChartType = ExcelChartType.BarClustered;

       //Set region of chart1 data
            chart1.DataRange = sheet.Range["B2:B5"];
       chart1.SeriesDataFromRange = false;
           
            Spire.Xls.Charts.ChartSerie cs1 = chart1.Series[0];
            cs1.CategoryLabels = sheet.Range["A2:A5"];

      //Set position of chart1
      chart1.LeftColumn = 1;
      chart1.TopRow = 30;
      chart1.RightColumn = 11;
       chart1.BottomRow = 60;
                 
            workbook.SaveToFile("result.xlsx", ExcelVersion.Version2010);

Please feel free to contact us if you have any questions or needs.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 804
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.XLS