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

  • Home
  • SEARCH
  • 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 6809559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:06:03+00:00 2026-05-26T20:06:03+00:00

I’m currently building a web app that will take some info from a database

  • 0

I’m currently building a web app that will take some info from a database and replace some text in a Word document with that information. Then the document will be saved to a predefined location.

Problem now is that when development began we were talking about 5 documents, but now we are looking at 20+ and documents will probably change over time. My intial thought was to “hardcode” classes for each document. But now that seems like a a really stupid idea.

The signature for the method would probably be something like: void Generate(string template, string outputFileName);. How is this done in the best way? Let’s say I create an interface IGenerator which defines the Generate method and some method to describe the current “plugin”. Could I then simply put .cs-files (or dlls) with a single class implementing that interface in some directory and then let the application find all these and let the user choose one?

EDIT: Is there a good way to add/edit/delete these Document-classes without having to recompile the entire app or library with all classes? I would like each Document-class to stand for itself. I’ve read this article, which might be my best choice?

Thanks.

  • 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-05-26T20:06:04+00:00Added an answer on May 26, 2026 at 8:06 pm

    I would look at using a Factory Pattern to produce your document instances and if you need to deal with different document types then think about having an Document abstract class that exposes overrideable methods for getting data from and into a document.

    You then code to handle the Document class and not specific child classes as the rest of your code doesn’t care what the document is, only that it is handling one.

    You would then need to implement a Document sub-class to cope with different document types (Word .doc, .docx; Excel, Text etc.) and generate an instance of the correct class by using a Document Factory to which you pass a variable to determine the creation of the correct Document sub-class.

    If you are to have multiple documents in existance at anyone time then you store instances of them in a List<Document>.

    edit

    Well here’s my thinking based on what you’ve stated so far.
    You’re really only dealing with Office documents and so you can either use an Office SDK, in which case you’ll need to load up the appropriate library or if you stick to Open XML format documents, you can produce them yourself.

    Have a look here for information on Office document formats.

    In any case you’ll be dealing with say a Word document or an Excel document, but you may have multiple layouts of a Word document.

    If you write your document class to accept template information of some sort then you can store this in XML either in your database or within a config file.

    If storing within a config file then reference it as a data source from your web.config e.g.

    <appSettings datasource="different.config"/>
    

    That way you can make changes to the appSettings stored within different.config without needing to restart your web pages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
Does anyone know how can I replace this 2 symbol below from the string
I have a reasonable size flat file database of text documents mostly saved in

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.