She once said, everyone has a password, see if my key can unlock your password.
Hey，How are you doing?
I’m a professional code. Nice to meet you.
Once upon a time, I felt that the relationship between C Chen and me was very much like the rough love road between Gu Shengnan and Lu Jin.
C 訙 with strict structure is like Lu Jin with poisonous tongue. Whenever there is a mistake, he will talk about me in various jump frames.
In order to taste delicious food, Lu Jin plunges into Gu Sheng men’s house.
And I’m buried in the coding world for debugging code.
Today, I will show you the realization process of C ා automatically generating payslip.
001 preparatory work
- Excel initialization
Excel instantiation declaration:
Excel._ApplicationEap = newExcel.Application();
Set Excel application visible:
Set excel path:
Open excel file:
Excel._WorkbookEbk = Eap.Workbooks.Open(ePth);
- Word initialization
Declare instantiation of word application:
Word._ApplicationWap = newWord.Application();
Set word application visible:
Set word path:
Open word file:
Word._DocumentWdc = Wap.Documents.Open(Pth);
- Drawing tables, formatting
Set word table maximum row excel valid row-1:
intMxr = Eap.Worksheets.UsedRange.CurrentRegion.Rows.Count-1;
Table instantiation, line adding and text centering:
Word.TableWtb = Wdc.Tables;
002 start work
By S%2==1Control, using WTB.Cell(s,j).Range.Text=Eap.Worksheets.Cells(1,j).valueWrite the title to an odd number of lines.
By S=2,s+=2;i=2, I + + control, using EAP.Worksheets.Cells(i,j).value.ToString()Write data to even rows.
Where. ToString (“yyyy mm”)Implement date formatting.
Where. ToString (“0.00”)Format the number.
003 finishing work
utilizeEapsht.Kill(Eap)，callKill()Method to complete the terminationExcelProcess.
Finally, post the code and replySource codeTo get the code source file.
Lu Jin said, Xie Shengnan, you are not the most beautiful, nor the ugliest.
No matter what kind of language you are learning, the best thing is what suits you.
I hope you can also be like love every day, even if sometimes not happy, but also adhere to life.
Maybe one day, you can also like Lu Jin, Xie Shengnan, because of efforts and embrace a better future!
———— The End ————