Hello Everyone,
I exported a gridview to excel spreadsheet. I want to adjust the column
width of the excel spreadsheet.
Is it possible to create Excel macro from C# to adjust the column width of
the spreadsheet. Below is my code for exporting to excel
string attachment = "attachment ; filename=Contac ts.xls";
Response.ClearC ontent();
Response.AddHea der("content-disposition", attachment);
Response.Conten tType = "applicatio n/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter( sw);
HtmlForm frm = new HtmlForm();
dgAgentActivity .Parent.Control s.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Ad d(dgAgentActivi ty);
frm.RenderContr ol(htw);
Any help will be greatly appreciated.
Thanks. 2 4473
"Vinki" <Vi***@discussi ons.microsoft.c omwrote in message
news:2D******** *************** ***********@mic rosoft.com...
Hello Everyone,
I exported a gridview to excel spreadsheet. I want to adjust the column
width of the excel spreadsheet.
Is it possible to create Excel macro from C# to adjust the column width
of
the spreadsheet. Below is my code for exporting to excel
string attachment = "attachment ; filename=Contac ts.xls";
Response.ClearC ontent();
Response.AddHea der("content-disposition", attachment);
Response.Conten tType = "applicatio n/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter( sw);
HtmlForm frm = new HtmlForm();
dgAgentActivity .Parent.Control s.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Ad d(dgAgentActivi ty);
frm.RenderContr ol(htw);
Any help will be greatly appreciated.
Thanks.
You can use the Microsoft Office Primary Interop Assemblies. These allow
you to add a references which gives you access to COM components and let you
do just about anything with an office application.
Look up http://msdn2.microsoft.com/en-us/lib...57(VS.80).aspx
Here you should find out which reference to add, and information about
classes and methods.
No, it's not possible using your technique. You are better off trying an
Interop approach or using the OWC.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$19.99
"Matt Brunell" <ma**@fast-soft.comwrote in message
news:80******** *************** ***********@mic rosoft.com...
"Vinki" <Vi***@discussi ons.microsoft.c omwrote in message
news:2D******** *************** ***********@mic rosoft.com...
>Hello Everyone,
I exported a gridview to excel spreadsheet. I want to adjust the column width of the excel spreadsheet. Is it possible to create Excel macro from C# to adjust the column width of the spreadsheet. Below is my code for exporting to excel
string attachment = "attachment ; filename=Contac ts.xls"; Response.ClearC ontent();
Response.AddHea der("content-disposition", attachment); Response.Conten tType = "applicatio n/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter( sw); HtmlForm frm = new HtmlForm();
dgAgentActivity .Parent.Control s.Add(frm); frm.Attributes["runat"] = "server"; frm.Controls.Ad d(dgAgentActivi ty); frm.RenderContr ol(htw);
Any help will be greatly appreciated.
Thanks.
You can use the Microsoft Office Primary Interop Assemblies. These allow
you to add a references which gives you access to COM components and let
you do just about anything with an office application.
Look up http://msdn2.microsoft.com/en-us/lib...57(VS.80).aspx
Here you should find out which reference to add, and information about
classes and methods.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mrs Howl |
last post by:
I don't know if there's even a way to do what I want. I click on a
button in an Access form, and it opens an instance of Excel, and opens
a workbook and runs a macro that's in it. So far, fine, I know how
to do this. I'm preferring to keep the Excel instance invisible, but
while the macro is running, it would be nice to see some sort of
progress indicator.
(By the way, here's basically what the Excel macro is doing: it's
opening...
|
by: Alex |
last post by:
i have a module in Access which opens an existing Excel file and
envokes a macro within the Excel file to draw graphs. now i am trying
to convert the Excel macro to an Access one so that the converted
Access macro can do the same thing as the Excel macro does when i open
the Excel file.
Can anybody give me a hint? Thanks in advance!
Alex
|
by: geronimo_me |
last post by:
Hi,
I am trying to run an Excel macro from an Access module, however when I
run the code the macro runs but then I get an error in Access. The
error is: Run-time error "440", Automation error.
My code is:
Sub Run_Excel_Macro()
Dim xls, xlWB As Object
|
by: TommyBoy |
last post by:
i'm trying to call an excel macro from C#, but i have never done it
before, and advice? can you pass an argument to a macro.. if so how?
Thanks in advance
|
by: cr113 |
last post by:
I just upgraded from Office 2000 to Office 2003. My VB.NET Excel macro
calls don't work any longer.
Here is how I make my Excel macro call from VB.NET:
Dim objExcel as Excel.Application
objExcel = New Excel.Application
objExcel.Workbooks.Open(FileName:="c:\test.xls", ReadOnly:=True)
objExcel.Run("test.xls!test.test")
| |
by: cr113 |
last post by:
We've upgraded from Office 2000 to Office 2003 and now my excel macro
calls are messed up. There's about a 15 second delay from the time I
make the call in VB.NET to the time the excel macro is actually
executed.
Here's my code:
Dim oExcel As Microsoft.Office.Interop.Excel.Application
oExcel = New Microsoft.Office.Interop.Excel.Application
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
Hello Everyone,
I exported a gridview to excel spreadsheet. I want to adjust the column
width of the excel spreadsheet.
Is it possible to create Excel macro from C# to adjust the column width of
the spreadsheet. Below is my code for exporting to excel
string attachment = "attachment; filename=Contacts.xls";
Response.ClearContent();
|
by: redbenn |
last post by:
Hello,
I am trying to create an excel macro, that when clicked... a specific cell will match a record in my database, and update certain fields in this record.
The Excel file will have a cell that is the same as a 'Tracking Number' (the primary key) of my Access Table. The output from excel would access this record and update the field.
I currently have a macro to create new records in the table, but I am not sure if there is a way to...
|
by: MitchR |
last post by:
Good Morning Folks;
I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA generated Excel spreadsheet from an Access Module. I can create the spreadsheet, button, and I have the macro to insert into command button. But I am not sure how to assign the macro to the button in the access module.
Set xlApp =...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |