terça-feira, 6 de março de 2012 05:57
I am getting the exception while applying the formatting to the excel worksheet using Macros in C#..
My C# application produces the output in Excel document.. The excel document consist of thousands of records and i wanted to produce line charts for the records.. So i used the Macros to create dynamic line charts and to apply some formatting style to the charts and contents of the worksheets...
I succeeded in the creation of macros to apply format and to create line charts using C#. But I have a strange thing that occurs few times.. Many times it runs without any exceptions and sometimes it throws the exceptions while applying the formatting font name, size, its style and so on...
The example code is follows..
With Selection.Font .Name = "Calibri" .Size = 16 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ThemeColor = xlThemeColorAccent1 .TintAndShade = -0.249977111117893 .ThemeFont = xlThemeFontMinor End With
The exception like cannot apply the style gets throws whenever i apply the formatting..
Kindly help me to solve this issue..
Thakns in advance..
Todas as Respostas
sexta-feira, 9 de março de 2012 04:04Moderador
Thanks for posting in the MSDN Forum.
As you said "But I have a strange thing that occurs few times.. Many times it runs without any exceptions and sometimes it throws the exceptions while applying the formatting font name, size, its style and so on...". I want to know the expection's details. And I also want to reproduce your issue on my side. So I need your Excel version and Visual Studio version.
Have a good day,
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
terça-feira, 13 de março de 2012 05:50
Very thanks for your reply..
For now, I am not receiving those errors since I changed the font styles to the "Times New Roman" and basic formatting.. The error messages I got before was like Cannot apply the "Font Name and Styles" to the particular range..
terça-feira, 13 de março de 2012 20:22Moderador
Good news. Changing the font has stopped the error. Some of the other browsers in
this Forum may be able to suggest how to substitute multiple fonts to give your
graph the format you want.
You can see the equivalent of the required C# code by recording a VBA macro in
Excel then following that in your C# project.
You said you were getting an Exception before but didn’t share the explicit wording
of that exception message. The exact wording can be a useful query string to
use when browsing the VKB for similar occurrences of that message.
If you need more responsive help you should include a post with instructions on
how to build a project similar to yours, or links to a SkyDrive workspace where
you have saved a zip of your C# project.
Senior Technical Support Lead