Excel fix; Records table fix;
This commit is contained in:
@@ -5,7 +5,7 @@ import { UntypedFormGroup, UntypedFormBuilder, FormsModule, ReactiveFormsModule
|
||||
import { MatSort, MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Layer, LayerType } from 'src/app/models/layer.model';
|
||||
import { Layer } from 'src/app/models/layer.model';
|
||||
import { Record } from 'src/app/models/record.model';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
@@ -55,18 +55,34 @@ export class LayerDetailComponent implements OnInit {
|
||||
this.form.disable();
|
||||
this.document.created = `${this.datePipe.transform(this.document.createdAt?.toDate(), 'short')}, ${this.document.createdBy?.userName}`;
|
||||
this.valueSum = this.document.records.map(t => t.value1 || 0).reduce((acc, value) => acc + value, 0);
|
||||
if (this.document.type === LayerType.Processed) {
|
||||
this.displayedColumns = ['code', 'value1', 'value2', 'value3', 'value4',
|
||||
'value5', 'value6', 'value7', 'value8', 'value9', 'value10', 'value11',
|
||||
'value12', 'value13', 'value14', 'value15', 'value16', 'value17', 'value18',
|
||||
'value19', 'value20', 'value21', 'value22', 'value23', 'value24', 'value25',
|
||||
'value26', 'value27', 'value28', 'value29', 'value30', 'value31'];
|
||||
}
|
||||
this.createColumns();
|
||||
}
|
||||
private async load(): Promise<Layer> {
|
||||
return await Layer.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$);
|
||||
}
|
||||
|
||||
createColumns() {
|
||||
this.displayedColumns = ['code'];
|
||||
for (let i = 1; i < 32; i++) {
|
||||
for (const record of this.document.records) {
|
||||
const propertyName = `value${i}` as keyof typeof record;
|
||||
if (record[propertyName] !== null) {
|
||||
this.displayedColumns.push(`value${i}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 1; i < 6; i++) {
|
||||
for (const record of this.document.records) {
|
||||
const propertyName = `desc${i}` as keyof typeof record;
|
||||
if (record[propertyName] !== null) {
|
||||
this.displayedColumns.push(`desc${i}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async export() {
|
||||
if (await Layer.exportToGoogleSheet(this.document.id || "", this.http$)) {
|
||||
this.notifications$.add({
|
||||
|
||||
@@ -28,7 +28,12 @@ namespace WebAPI.Exports
|
||||
List<IList<object>> data = new List<IList<object>>() { new List<object>() { layer.Name! } };
|
||||
foreach (Record record in layer.Records!)
|
||||
{
|
||||
data.Add(new List<object> { record.Code!, record.Value1! });
|
||||
data.Add(new List<object> { record.Code!, record.Value1!, record.Value2!, record.Value3!, record.Value4!,
|
||||
record.Value5!, record.Value6!, record.Value7!, record.Value8!, record.Value9!, record.Value10!,
|
||||
record.Value11!, record.Value12!, record.Value13!, record.Value14!, record.Value15!, record.Value16!,
|
||||
record.Value17!, record.Value18!, record.Value19!, record.Value20!, record.Value21!, record.Value22!,
|
||||
record.Value23!, record.Value24!, record.Value25!, record.Value26!, record.Value27!, record.Value28!,
|
||||
record.Value29!, record.Value30!, record.Value31!});
|
||||
}
|
||||
|
||||
Google.Apis.Drive.v3.Data.File body = new Google.Apis.Drive.v3.Data.File();
|
||||
@@ -39,7 +44,7 @@ namespace WebAPI.Exports
|
||||
var file = request.Execute();
|
||||
|
||||
string sheetId = file.Id;
|
||||
var range = $"Sheet1!A1:B${data.Count}";
|
||||
var range = $"Sheet1!A1:AF${data.Count}";
|
||||
|
||||
ValueRange valueRange = new ValueRange() { Values = data};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user