Hi all,
In an effort to try to impress the boss, I would like to log accounting information to an Excel spreadsheet using C# and .NET. This would be a mockup only, not a real solution - yet!
We are a small ticketing company - not a bunch of IT whiz kids. ...but I do have an IT background.
I have been successful in logging (printing) tickets to a word document, and it all works kinda cool.
However, I wish to log to same information to an Excel document. For example, I want to log each ticket on a new row of a spreadsheet. Alas, writing to an excel document is not as easy as writing to Word.
So I would need to (1) create a new Excel document, if it did not exist, (2) Write the ticket information on the NEXT row of a spreadsheet, (3) Save and close the file. I am looking at writing a new function/method called "public void Log" to do this.
How would I do this? Can someone provide an example of how to create and save a new Excel document? And then write data to the rows?
Thankyou so very much in advance!
Ticketing printing code using .NET and C#:
class Ticket
{
public Event e;
public String Section;
public String Type;
public String Price;
public String Comment;
private Word.Applicatio nClass WordApp = null;
private Word.Document Paper = null;
public void Open()
{
if (WordApp == null)
{
object Missing = System.Reflecti on.Missing.Valu e;
object FileName = "normal.dot ";
object NewTemplate = false;
object DocType = 0;
object isVisible = true;
WordApp = new Word.Applicatio nClass();
Paper = WordApp.Documen ts.Add(ref FileName, ref NewTemplate, ref DocType, ref isVisible);
WordApp.Visible = true;
Paper.Activate( );
}
return;
}
public void Close()
{
if (WordApp != null)
{
object Missing = System.Reflecti on.Missing.Valu e;
object FileName = "ticket.doc ";
Paper.SaveAs(re f FileName, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);
Paper.Close(ref Missing, ref Missing, ref Missing);
WordApp.Quit(re f Missing, ref Missing, ref Missing);
WordApp = null;
}
return;
}
public void Print()
{
if (WordApp != null)
{
WordApp.Selecti on.ParagraphFor mat.Alignment = Word.WdParagrap hAlignment.wdAl ignParagraphCen ter;
WordApp.Selecti on.Font.Bold = (int) Word.WdConstant s.wdToggle;
WordApp.Selecti on.TypeText("Ti cket Information");
InsertBlankLine s(1);
WordApp.Selecti on.Font.Bold = (int) Word.WdConstant s.wdToggle;
WordApp.Selecti on.ParagraphFor mat.Alignment = Word.WdParagrap hAlignment.wdAl ignParagraphLef t;
WordApp.Selecti on.TypeText("\n Event:\t" + e.Name);
WordApp.Selecti on.TypeText("\n Theatre:\t" + e.Venue);
WordApp.Selecti on.TypeText("\n Date:\t" + e.DateAndTime);
WordApp.Selecti on.TypeText("\n Section:\t" + Section);
WordApp.Selecti on.TypeText("\n Type:\t" + Type); WordApp.Selecti on.TypeText("Pr ice:\t" + Price);
WordApp.Selecti on.TypeText("\n Additional Information: " + Comment);
WordApp.Selecti on.TypeText("\n Date Printed:\t"); InsertTimeDate( );
InsertBlankLine s(2);
}
return;
}
private void InsertBlankLine s(int number)
{
if (WordApp != null)
{
int iCount = 0;
for (iCount = 0; iCount < number; ++iCount)
{
WordApp.Selecti on.TypeParagrap h();
}
}
return;
}
private void InsertTimeDate( )
{
if (WordApp != null)
{
object Missing = System.Reflecti on.Missing.Valu e;
object False = false;
object objDate = "dddd, MMMM dd, yyyy at HH:mm:ss";
WordApp.Selecti on.InsertDateTi me(ref objDate, ref False, ref Missing, ref Missing, ref Missing);
WordApp.Selecti on.TypeParagrap h();
}
return;
}
} 0 3947 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alan |
last post by:
Hi there,
Are there Excel charting gurus here?? If so then please read on...
Sorry for the cross-post but I'm not familiar with the Excel groups. I've
posted to asp.general because if I have to code a solution to this it'll
probably be done in ASP on a web server, unless there's a significantly
better way.
I'm looking for a way to create over 100 Excel *charts* programmatically.
|
by: Alan |
last post by:
Hi there,
Are there Excel charting gurus here?? If so then please read on...
Sorry for the cross-post but I'm not familiar with the Excel groups. I've
posted to asp.general because if I have to code a solution to this it'll
probably be done in ASP on a web server, unless there's a significantly
better way.
I'm looking for a way to create over 100 Excel *charts* programmatically.
|
by: Kerri McDonald |
last post by:
We have an application where the user fills out many screens and when
they are done, we are supposed to display the text they entered in a
word or excel format. That is fairly easily accomplished by changing
the content type in the response object.
On one of the screens where they enter data, they also have the
ability to upload a word document containing additional information.
This is also not a problem, and is working fine.
Now they...
|
by: Guy Incognito |
last post by:
Hello,
I've written an asp.net application that creates Excel documents. It
works by creating an excel document in XML format.
But I wonder if I'm reinventing the wheel. I know that there are ways to
read and write Excel files with ADO, but as far as I can tell, it
doesn't provide the flexibility I need. I need to be able to generate
tabs, cell formatting, formulas, etc.
|
by: Paul |
last post by:
Hi all
Arggghhh...........
The problem.....I want the user to be able to create an excel document and
name particular cells in the document where they want the data to be placed
and then save this out of an XML file or Excel Template file.
Next I need to convert a dataset to xml and try and transform this data into
the users xml file..........i've seen a few things on this but havent had
much success...
| |
by: Michael Groeger |
last post by:
Hi,
I have an aspx page which generates an excel document and transfers it to
the browser as attachment. Normally, once the document is transferred the
open save dialog prompts to open or save the excel document. When I click
save I can save the excel document or when I click open it directly opens in
excel. This works fine for all but one machine.
On one machine however the dialog prompts to open or save the excel document
(e.g....
|
by: Paul |
last post by:
Hi I have created an excel file download feature within a .net application
using Microsoft Office XP primary interop assembly for excel. I was just
wondering if anyone knows if you can also embed excel formulas in the excel
download, for example a running total on a column, thanks.
--
Paul G
Software engineer.
|
by: Andy Burchill |
last post by:
Hi there,
I am trying to find out what the best way of creating an excel
spreadsheet is, this will need to be done dynamically by an aspx website
on the server side.
The main way would be to use the Excel com object that is available when
you have excel installed, however since this is done server side I need
to be sure that it won't generate any dialog box error messages. There
are also concerns about threading.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |