Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:55:48+00:00 2026-06-14T09:55:48+00:00

I have a desktop app in which I generate an excel file from a

  • 0

I have a desktop app in which I generate an excel file from a template, basically what I do is to make a copy of the template excel file to a new directory, open it, and add records to it.

this is a code snippet:

string ExcelFiles = txtFileOutput.Text; //Application.StartupPath + @"\ExcelFiles\"; 
        string DestFile = ExcelFiles + FinalListOfTrucks[0].Date.ToShortDateString().Replace('/', '_') + ".xlsx"; 
        if (File.Exists(DestFile))
        {
            try
            {
                File.Delete(DestFile);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error deleting file: " + ex.Message);
            }
        }

        try
        {
            File.Copy(Application.StartupPath + @"\ExcelTemplate.xlsx", DestFile);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error copying file: " + ex.Message);
        }

        string appPath = Path.GetDirectoryName(Application.ExecutablePath);            
        string strConnectionXls = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + DestFile + ";Extended Properties=Excel 12.0;";
        OleDbConnection cno = new OleDbConnection(strConnectionXls);
        OleDbCommand cmo = new OleDbCommand();
        cmo.Connection = cno;
        cmo.CommandType = CommandType.Text;

string QueryHeader = "INSERT INTO [RptTotal$] (NUMERO,FECHA,JORNADA,PLACA,HORA_DE_LLEGADA,HORA_FIN_CARGUE,HORA_FIN_DESCARGUE,VOLUMEN,DISTANCIA,TIPO_DE_VEHICULO,MATERIAL,MISSED_DATE)";

cmo.CommandText = QueryHeader + " VALUES ('" + No.ToString() + "','" + Fecha + "','" + Jornada + "','" + Placa + "','" + HoraDeLlegada + "','" + HoraFinCargue + "','" +
                                                        HoraFinDescargue + "','" + Volumen + "','" + Distancia + "','" + TipoDeVehiculo + "','" + Material + "','" + MissedDate + "')";
                cmo.ExecuteNonQuery();

Now, let’s say that I can Add a folder to my webapp, and place the excel template there, how to start from there to achieve the same functionality in web :\ ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:55:49+00:00Added an answer on June 14, 2026 at 9:55 am

    Same thing you are doing on your desktop application, just need to clean up your code.

    1. Copy template, save templete same where in your server
    2. Need to remove all message boxes
    3. Use OleDbConnection to modify your excel file( would strongly recommed OpenXML or libraries build on top of openXML like Epplus)
    4. Save changes
    5. Stream the file to client
    6. Figure out how to clean streamed files
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PRISM desktop app which loads modules from a directory with the
I have one desktop application which was implemented in C#. This app uploads file
I have few apps (driver detective) which communicate with there site from desktop app.
We currently have a desktop app which uses data from SQL CE. We used
I have desktop AIR app which has been signed with a valid certificate from
I have a desktop app that has 65 modules, about half of which read
So, I have this desktop app built using WPF and C#. It's basically an
Here's my use case. I have a desktop app that can download from my
I have an .NET 4 .exe (Winform Desktop app) to which I have added
In a Java desktop app with SWT-based GUI, we have a table in which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.