Click here to Skip to main content
14,771,570 members
Home » Discussions » C#
   

C#

 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 3:41
mveOriginalGriff16-Nov-20 3:41 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 3:48
MemberAlex Dunlop16-Nov-20 3:48 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 3:50
mveOriginalGriff16-Nov-20 3:50 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 4:09
MemberAlex Dunlop16-Nov-20 4:09 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 4:40
mveOriginalGriff16-Nov-20 4:40 
GeneralRe: How to make a dll library? Pin
Alex Dunlop16-Nov-20 5:15
MemberAlex Dunlop16-Nov-20 5:15 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 5:37
mveOriginalGriff16-Nov-20 5:37 
GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 6:41
mveOriginalGriff16-Nov-20 6:41 
Excellent.
First off, change the way you fill your DGV. Instead of adding columns and rows directly, create a DataTable instance instead, populate that, adn set that as the DataSource property of the DGV.

The DGV will now display the data and update it as you add items to the underlying DataTable.

When you want to output the data to XLSX, pass the DataTable instance to your method:
private DataTable theSource = new DataTable();
private void FrmMain_Shown(object sender, EventArgs e)
    {
    theSource.Columns.Add("Column 1");
    theSource.Columns.Add("Column 2");
    theSource.Rows.Add("cccc1111", 666);
    myDataGridView.DataSource = theSource;
    }
private void AddButton_Click(object sender, EventArgs e)
    {
    theSource.Rows.Add(DateTime.Now, "hello");
    }

private void OutputButton_Click(object sender, EventArgs e)
    {
    MyDLLAssemblyClass.OutputToXLSX(theSource, @"d:\Test Data\myFile.xslx");
    }

private static void OutputToXLSX(DataTable dt, string outputPath)
    {
    ...
    }
You can then just add a using line for System.Data to your DLL assembly class and use the Row and Column from the DataTable.

Now your DLL file doesn't need to know what the heck the rest of your code is doing, it just wants a DataTable with the data to output.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: How to make a dll library? Pin
OriginalGriff16-Nov-20 3:21
mveOriginalGriff16-Nov-20 3:21 
QuestionC# WPF MenuItem Control not working Pin
Member 783087415-Nov-20 10:01
MemberMember 783087415-Nov-20 10:01 
AnswerRe: C# WPF MenuItem Control not working Pin
Mycroft Holmes15-Nov-20 12:03
professionalMycroft Holmes15-Nov-20 12:03 
GeneralRe: C# WPF MenuItem Control not working Pin
Member 783087417-Nov-20 15:51
MemberMember 783087417-Nov-20 15:51 
QuestionHow to group an array list, within a list of records, Linq GroupBy Pin
jkirkerx14-Nov-20 14:29
professionaljkirkerx14-Nov-20 14:29 
AnswerRe: How to group an array list, within a list of records, Linq GroupBy Pin
Gerry Schmitz14-Nov-20 23:31
mveGerry Schmitz14-Nov-20 23:31 
QuestionA proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286214-Nov-20 10:10
MemberMember 1499286214-Nov-20 10:10 
SuggestionRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Richard MacCutchan14-Nov-20 7:07
mveRichard MacCutchan14-Nov-20 7:07 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286214-Nov-20 10:10
MemberMember 1499286214-Nov-20 10:10 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
OriginalGriff14-Nov-20 10:16
mveOriginalGriff14-Nov-20 10:16 
AnswerRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Mycroft Holmes14-Nov-20 13:18
professionalMycroft Holmes14-Nov-20 13:18 
GeneralRe: A proper way to return a list (Xamarin, CollectionView, Realm) Pin
Member 1499286216-Nov-20 9:17
MemberMember 1499286216-Nov-20 9:17 
QuestionHow to selected value of a dropbox column of a DataGridView programmatically? Pin
Alex Dunlop13-Nov-20 1:41
MemberAlex Dunlop13-Nov-20 1:41 
AnswerRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard MacCutchan13-Nov-20 2:55
mveRichard MacCutchan13-Nov-20 2:55 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard Deeming13-Nov-20 3:06
mveRichard Deeming13-Nov-20 3:06 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Richard MacCutchan13-Nov-20 3:16
mveRichard MacCutchan13-Nov-20 3:16 
GeneralRe: How to selected value of a dropbox column of a DataGridView programmatically? Pin
Alex Dunlop13-Nov-20 4:09
MemberAlex Dunlop13-Nov-20 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.