c#


Multiple x axes and y axes in Excel converting to pdf by c#


I have been working in an ASP.NET MVC (C#) application in Visual Studio 2012. I have to create an Excel document with tables and charts and convert it to pdf using c#. But, some of my charts have multiple x axes and a secondary y axis (in the same time). Please help how to implement them in Excel (Office 2010). The example of code that I have used for one x and one y axes is here:
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
//add data
xlWorkSheet.Cells[1, 1] = "";
xlWorkSheet.Cells[1, 2] = "Student1";
xlWorkSheet.Cells[1, 3] = "Student2";
xlWorkSheet.Cells[1, 4] = "Student3";
xlWorkSheet.Cells[2, 1] = "Term1";
xlWorkSheet.Cells[2, 2] = "80";
xlWorkSheet.Cells[2, 3] = "65";
xlWorkSheet.Cells[2, 4] = "45";
xlWorkSheet.Cells[3, 1] = "Term2";
xlWorkSheet.Cells[3, 2] = "78";
xlWorkSheet.Cells[3, 3] = "72";
xlWorkSheet.Cells[3, 4] = "60";
xlWorkSheet.Cells[4, 1] = "Term3";
xlWorkSheet.Cells[4, 2] = "82";
xlWorkSheet.Cells[4, 3] = "80";
xlWorkSheet.Cells[4, 4] = "65";
xlWorkSheet.Cells[5, 1] = "Term4";
xlWorkSheet.Cells[5, 2] = "75";
xlWorkSheet.Cells[5, 3] = "82";
xlWorkSheet.Cells[5, 4] = "68";
xlWorkSheet.Cells[1, 2].Font.Bold = true;
xlWorkSheet.Cells[1, 3].Font.Bold = true;
xlWorkSheet.Cells[1, 4].Font.Bold = true;
Excel.Range chartRange;
Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
Excel.Chart chartPage = myChart.Chart;
chartRange = xlWorkSheet.get_Range("A1", "d5");
chartPage.SetSourceData(chartRange, misValue);
chartPage.ChartType = Excel.XlChartType.xlColumnClustered;
myChart.Chart.Legend.Position = Microsoft.Office.Interop.Excel.XlLegendPosition.xlLegendPositionTop;
myChart.Chart.HasTitle = true;
myChart.Chart.ChartTitle.Text = "Test Tilte";
int numberOfPages = xlWorkSheet.PageSetup.Pages.Count;
// Page numbers as well for the PDF file (hopefully)
xlWorkSheet.PageSetup.FirstPageNumber = 1;
xlWorkSheet.PageSetup.CenterFooter = "&\"Calibri\" &8 Page &P of " + numberOfPages;
xlWorkBook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, "z:\\Brisi\\ExcelToPdf.pdf");
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
Thank you in advance for any help!

Related Links

sql syntax how to do a join?
C++ / Java / C# Image processing library
Array of string from Arraylist of Arraylist
How to find the 3rd Friday in a month with C#?
Cannot consume WSDL in VS2010
How to launch DatePickerPage from ApplicationBarIconButton?
have pdb file still cant debug
Dynamically reloading classes in C# (looping through all instances)
Dictionary throws exception even after checked for null
problem loading image from db pathname
Array of Lists throws NullReferenceException
Nhibernate session management strategy for web application with background-workers?
Matching failed messages to their exceptions in NServiceBus using MSMQ
dependency properties in Silverlight
Shallow vs. Deep Copies in Immutable Objects
Recognize if the client is requesting page or something else in ASP.NET MVC custom HttpModule?

Categories

HOME
spring-boot
kendo-ui-angular2
sip
jenkins-pipeline
blob
stdout
app-store
esxi
sms
google-docs-api
thermal-printer
opacity
kendo-asp.net-mvc
android-webview
samsung-gear-s2
angularjs-ng-repeat
select2
adroitlogic
watson-dialog
loss
game-engine
smooth-scrolling
indri
draw2d
autologin
django-rest-auth
hololens
pumping-lemma
uipath
ckeditor4.x
scalatest
pushpad
ipython-parallel
flickr
ponylang
leaderboard
sdl-2
ui-grid
qt-quick
activeandroid
serverless-architecture
jsfl
confluent
google-cloud-shell
r-commander
kendo-scheduler
androiddesignsupport
liferay-ide
zedgraph
timex
vertex-shader
timefield
consolidation
dimensionality-reduction
settext
angularfire
aws-kms
ideavim
firefox-os
gtkwave
log4cxx
tess4j
joomla3.3
xml-simple
qxorm
quickfixn
caption
frisby.js
mind-manager
go-gin
pnunit
oxygenxml
im4java
email-headers
slimscroll
mdp
adabas
mysql-error-1146
grunt-contrib-imagemin
myrrix
ojb
nokogiri
oc4j
azure-pack
stringstream
dynamic-expresso
backbone-views
rfc822
junit-rule
wpml
scsf
umfpack
log-shipping
azure-appfabric

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile